Hello,
When I create a DateTime object from a UNIX timestamp, and then add a
one day interval, PHP adds 25 hours instead of 24. Is this a bug, or
something to do with the time zones?
Here are the commands I'm running from my shell:
----------
$ date
Wed Jun 13 06:08:24 PDT 2012
$ php -r '$d=new DateTime("@1082444400"); print $d->format("r")."\n";
$d->add(new DateInterval("P1D")); print $d->format("r")."\n";'
Tue, 20 Apr 2004 07:00:00 +0000
Wed, 21 Apr 2004 08:00:00 +0000
----------
If I set the time zone on the new DataTime object to America/Los_Angeles
before adding the 1 day period, then it works as expected.
----------
$ php -r '$d=new DateTime("@1082444400"); $d->setTimeZone(new
DateTimeZone("America/Los_Angeles")); print $d->format("r")."\n";
$d->add(new DateInterval("P1D")); print $d->format("r")."\n";'
Tue, 20 Apr 2004 00:00:00 -0700
Wed, 21 Apr 2004 00:00:00 -0700
----------
Regards,
Shailesh
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php