Advertise with us

php dates off by one day

Hi Everyone!

I am changing int(11) in a mysql database back into regular date formats (mm/dd/yyy) It is working fine except it appears to be one day 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 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 it should be returning: 07/01/2013 and it is returning: 06/30/2013

Thanks in advance! 
Last updated:5/18/2013 8:24:05 AM

1 Answers


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.


echo date('m/d/Y', $row['due_date]+$offset_in_seconds);

I hope it helpful for you.