Bug #66118 [Opn]: date_format prints incorrect GMT offset during time change hour

From: Date: Tue, 19 Nov 2013 16:20:46 +0000
Subject: Bug #66118 [Opn]: date_format prints incorrect GMT offset during time change hour
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-182832@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66118&edit=1 ID: 66118 User updated by: david dot sheldon at carrierweb dot com Reported by: david dot sheldon at carrierweb dot com Summary: date_format prints incorrect GMT offset during time change hour Status: Open Type: Bug Package: Date/time related Operating System: Linux, windows7 PHP Version: 5.5.6 Block user comment: N Private report: N New Comment: 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); Previous Comments: ------------------------------------------------------------------------ [2013-11-19 15:38:44] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66118&edit=1

« previous php.bugs (#182832) next »