Whilst working on a UI update for a client, I noticed the dates associated with all the articles were out by a day. I figured I'd screwed something up during my changes, but to be sure, threw together a little php test file that gave me some odd results. The test file is just;
<?php
$date = 1246053600;
echo 'unix: ',$date,', converted: ',date('d/m/Y', $date);
?>
If I run the above code on my localhost I get:
unix: 1246053600, converted: 26/06/2009
But if I run it on the production server I get:
unix: 1246053600, converted: 27/06/2009
Notice the day difference between the two? What's happening here?! Surely converting a unix timestamp to a date doesn't have any server specific dependancies?
Your servers might be set to two different time zones, and they're interpreting the timestamp as the number of seconds since midnight january 1st 1970 GMT. The dates may not be off by a whole day, but just part of a day, enough to make it cross over the midnight boundary.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With