---
title: "php dates off by one day"  
description: "php dates off by one day"  
author: "Anonymous User"  
published: 2013-05-18  
updated: 2013-05-18  
canonical: https://www.mindstick.com/forum/904/php-dates-off-by-one-day  
category: "php"  
tags: ["php"]  
reading_time: 1 minute  

---

# php dates off by one day

Hi Everyone!\
I am changing int(11) in a [mysql database](https://answers.mindstick.com/qa/38302/what-is-the-main-difference-between-innodb-myisam-mysql-database-engines) back into [regular](https://www.mindstick.com/forum/220/problem-in-regular-expression-in-javascript) date [formats](https://www.mindstick.com/forum/160705/explain-the-concept-of-datetime-formats-in-c-sharp) (mm/dd/yyy) It is [working fine](https://answers.mindstick.com/qa/95550/why-is-the-safari-browser-not-working-fine) except it appears to be [one day](https://answers.mindstick.com/qa/39936/in-2006-which-player-signed-a-one-day-contract-with-the-american-football-team-san-francisco-49ers-then-retired) behind. Any ideas on what could be causing this?\
The code I am using to change it from int(11) to mm/dd/yyy is below: (yes it is part of a larger script, this is just the [one line](https://www.mindstick.com/forum/159096/how-can-i-run-two-commands-in-one-line-in-windows-cmd) that includes the date.)\
echo "<td>" . date('m/d/Y', $row['due_date']) . "</td>";Wihout the td's:\
echo date('m/d/Y', $row['due_date]);In my particular [testing](https://www.mindstick.com/articles/1849/role-of-testing-in-software-development) it should be [returning](https://www.mindstick.com/news/2477/returning-ceo-bob-iger-dismisses-the-disney-apple-sale-as-pure-speculation): 07/01/2013 and it is returning: 06/30/2013\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by AVADHESH PATEL

Hi Ashish!\
How is the table getting populated? You need to check the server timezone and then while displaying it in date format add those number of hours and that should fix your problem.\
e.g if the source is GMT and you are expecting dates to be in sync with PST, then you need to add/subtract couple of hours.\
i.e\
echo date('m/d/Y', $row['due_date]+$offset_in_seconds);\
I hope it helpful for you.


---

Original Source: https://www.mindstick.com/forum/904/php-dates-off-by-one-day

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
