Edit report at http://bugs.php.net/bug.php?id=54481&edit=1
ID: 54481 User updated by: stuart at horuskol dot net Reported by: stuart at horuskol dot net Summary: date_default_timezone_get() returns incorrect timezone Status: Bogus Type: Bug Package: Date/time related Operating System: Linux/Ubuntu PHP Version: Irrelevant Block user comment: N Private report: N New Comment: I don't quite see why this is not a bug... Why, when I own my server(s) and want to be able to have a single point of configuration for timezones on that server (because of interoperating services like PHP and MySQL) instead of sharded configuration in separate files, can I not rely on my system timezone? In addition - since the error is because I don't have default timezone set - something is going wrong with the request to the server for the timezone. If you won't fix it, fair enough, but I don't think this is bogus. Previous Comments: ------------------------------------------------------------------------ [2011-04-08 11:40:03] der...@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php The guessing algorithm isn't perfect, that's why you *need* to make the date.timezone setting in php.ini. You will also get a warning when it's not set: derick@whisky:~$ php -n -r 'echo date_default_timezone_get(), "\n";' Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/London' for 'BST/1.0/DST' instead in Command line code on line 1 Europe/London So make sure you have display_errors on as well, as well as set error_reporting to include warnings. I've updated the documentation to reflect this. ------------------------------------------------------------------------ [2011-04-08 11:39:12] der...@php.net Automatic comment from SVN on behalf of derick Revision: http://svn.php.net/viewvc/?view=revision&revision=310049 Log: - Clarify the guessing stage of date_default_timezone_get() a bit to prevent bug reports such as #54481. ------------------------------------------------------------------------ [2011-04-07 04:21:10] stuart at horuskol dot net Description: ------------ We noticed a discrepancy between PHP and the server timezones, and found that one four different servers (with two different versions of PHP - 5.2.4 and 5.3.2) the server was set to Australia/Adelaide (ACST), but this date_default_timezone_get() was returning Asia/Jayapura (EIT). There is no value in date.timezone (it is commented out) in the CLI and Apache PHP configuration files - so according to the documentation, PHP should be getting the timezone from the server configuration. Why is it getting this random Asia/Jayapura value? --- >From manual page: http://www.php.net/function.date-default-timezone-get#Description --- Test script: --------------- echo date_default_timezone_get(); Expected result: ---------------- The correct timezone - not Asia/Jayapura when the server is set to Australia/Adelaide Actual result: -------------- Asia/Jayapura ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=54481&edit=1