Bug #62130 [Opn->Nab]: DateTime constructor accepts invalid TZ abbreviations

From: Date: Thu, 27 Aug 2015 16:47:11 +0000
Subject: Bug #62130 [Opn->Nab]: DateTime constructor accepts invalid TZ abbreviations
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195561@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62130&edit=1 ID: 62130 Updated by: cmb@php.net Reported by: kavi at postpro dot net Summary: DateTime constructor accepts invalid TZ abbreviations -Status: Open +Status: Not a bug Type: Bug Package: Date/time related Operating System: Linux PHP Version: Irrelevant -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: IMO it is not a bug to accept a timezone identifier for a timezone that may be currently not in use anywhere, because it is nonetheless a valid timezone identifier. If an invalid timezone identifier is given, an exception would be thrown, see <https://3v4l.org/bvLtc> > […] the modify() call didn't work and also didn't throw an > error. This bug has been fixed as of PHP 5.3.9, see <https://3v4l.org/m2O7M>. Previous Comments: ------------------------------------------------------------------------ [2012-05-23 19:52:49] kavi at postpro dot net Description: ------------ PHP will accept invalid DST-related time zone abbreviations, e.g. daylight savings time when daylight savings time cannot be in effect on the given date; subsequent operations on the returned object may produce invalid results. This should produce an error. Test script: --------------- $dt = new DateTime('1980-01-01 15:00:00 PDT'); print_r($dt); $dt->modify('+1 hour'); print_r($dt); Expected result: ---------------- EXPECTED output should be an error. Actual result: -------------- DateTime Object ( [date] => 1980-01-01 15:00:00 [timezone_type] => 2 [timezone] => PDT ) DateTime Object ( [date] => 1980-01-01 15:00:00 [timezone_type] => 2 [timezone] => PDT ) Note that PDT is invalid for the given date, and the modify() call didn't work and also didn't throw an error. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62130&edit=1

« previous php.bugs (#195561) next »