|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2013-11-19 15:38 UTC] david dot sheldon at carrierweb dot com
Description: ------------ For the hour where the clock changes, date() reports the correct offset/timezone abbreviation, and date_format() reports the incorrect offset, appearing to use the offset for an hour later. Test script: --------------- // http://3v4l.org/GVjMn date_default_timezone_set("America/New_York"); $timeStamp = 1352008800; $date= date(DateTime::ISO8601, $timeStamp); $dateTime = new DateTime(); $dateTime->setTimestamp($timeStamp); $dateFormat = date_format($dateTime, DateTime::ISO8601); echo "Date: $date\nDateFormat: $dateFormat\n"; Expected result: ---------------- Both lines the same: Date: 2012-11-04T01:00:00-0500 DateFormat: 2012-11-04T01:00:00-0500 Actual result: -------------- Date: 2012-11-04T01:00:00-0500 DateFormat: 2012-11-04T01:00:00-0400 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 21:00:01 2025 UTC |
It appears that this is caused by $dateTime->setTimestamp(). The following code works fine: $dateTime = new DateTime("@$timeStamp"); $dateTime->setTimezone(new DateTimeZone("America/New_York")); $dateFormat = $dateTime->format(DateTime::ISO8601);