Bug #20786
closed
PHP-5.3 Warnings concerning missing timezone settings
Added by Michiel Roos over 15 years ago.
Updated over 14 years ago.
Description
Warning: date() [function.date]: 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/Berlin' for 'CEST/2.0/DST' instead in /Users/michiel/htdocs/sources/typo3_src-4.3.trunk/t3lib/class.t3lib_div.php on line 4389
(issue imported from #M11587)
Files
Warning: date() [function.date]: 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/Berlin' for 'CEST/2.0/DST' instead in /Users/michiel/htdocs/sources/typo3_src-4.3.trunk/typo3/mod/tools/em/class.em_index.php on line 996
Solution:
Edit the php.ini file on your server e.g. with
vi /etc/php5/apache2/php.ini
Search for "date.timezone" and add or modirfy the line e.g. like this:
date.timezone = "Europe/Berlin"
DonĀ“t forget to restart apache e.g. by
apache2ctl graceful
You are telling me that you want to make this decision for ALL your clients, no matter in what country they live. If they host on your server, you impose YOUR region upon them?
That will not do. A more flexible solution is needed. Think of a timezone selector in the install tool.
Sure - this only makes sense for servers with clients/sites all from the same timezone.
This is not a Typo3 or PHP bug, it's normal behavior. Could this be closed as "Bogus"?
Christian,
Can you please explain clearly to me how this big warning popping up on my screen is 'bogus'.
Thank you.
I think, that it would be useful to have init.php set the timezone by a setting in localconf.php, as Michiel mentioned in Note 0029849 above.
PHP.INI setting should/could only be a default.
Christian,
On the page http://de3.php.net/manual/en/datetime.configuration.php#ini.date.timezone
It indeed says: date.timezone; default: ""
So, I installed a stock PHP that is configured 'as is' and I get a warning from the date() function.
That's how PHP is set up.
If an application like TYPO3 want's to use the date() function, it must initialize the correct TimeZone if there is none set by php.ini (which is the case by default).
hi,
I attached a patch which adds a new conf vars parameter "phpDateTimeZone" which sets the timezone to "CET" by default.
This is the same as "serverTimeZone" which is also set to CET (GMT+1) by default.
Here is a description of the "date.timezone" from the PHP documentation:
date.timezone string
The default timezone used by all date/time functions if the TZ environment variable isn't set.
This setting is PHP_INI_ALL. It is possible to configure this for each host separately in the vhost configuration or in the .htaccess.
Comments to my version of the patch (from the core list);
Proper solution should have two settings:
- "default time zone" (CET)
- "force time zone" (empty)
Proper algorithm:
- Is "force" setting empty?
|- "no" -> set it. The end
|- "yes" -> Is ini_get('date.timezone') value empty?
|-> "yes" set "default" setting. The end
|-> "no" Nothing to do. The end.
adjusted, latest patch attached
committet to trunk: r7468
Also available in: Atom
PDF