Bug #65313 [Opn->Nab]: DateTime::getLastErrors() does not include default timezone problems

From: Date: Fri, 12 Jun 2015 17:44:41 +0000
Subject: Bug #65313 [Opn->Nab]: DateTime::getLastErrors() does not include default timezone problems
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193361@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65313&edit=1 ID: 65313 Updated by: cmb@php.net Reported by: four dot zero dot one dot unauthorized at gmail dot com Summary: DateTime::getLastErrors() does not include default timezone problems -Status: Open +Status: Not a bug Type: Bug Package: Date/time related Operating System: any PHP Version: 5.4.17 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. When an invalid timezone specifier is passed to date_default_timezone_set() it is simply ignored, and that already triggers a notice. If that notice is not enough, check the return value of date_default_timezone_set(): | This function returns FALSE if the timezone_identifier isn't | valid, or TRUE otherwise. Previous Comments: ------------------------------------------------------------------------ [2013-07-23 03:15:19] four dot zero dot one dot unauthorized at gmail dot com Description: ------------ When ever date.timezone INI setting or date_default_timezone_set() is used and a clearly invalid timezone ID is set, DateTime::getLastErrors() has no indication of this. Same if no timezone is set. Test script: --------------- // assume date.timezone currently set to "America/Los_Angeles" for this test date_default_timezone_set( "asdf" ); try { $d = new DateTime(); } catch ( Exception $ex ) { var_dump( DateTime::getLastErrors() ); // never even reached - $d is actually valid and set to "America/Los_Angeles" timezone, and DateTime::getLastErrors() has no errors listed } ini_set( "date.timezone", "asdf" ); try { $d = new DateTime(); } catch ( Exception $ex ) { var_dump( DateTime::getLastErrors() ); // reached, but no errors listed here } Expected result: ---------------- DateTime::getLastErrors() always contains the "The timezone could not be found in the database" error if a bad timezone name is preset, or "You are *required* to use the date.timezone setting or the date_default_timezone_set() function" error if no timezone name is preset. Actual result: -------------- DateTime::getLastErrors() contains no such errors or warnings. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65313&edit=1

« previous php.bugs (#193361) next »