Fixing Warning: date() [] in PHP 5.3 [solved]

If you recently upgraded to a newer version of PHP, like PHP 5.3, you may be getting some errors similar to this in your PHP scripts:

Warning: 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 ‘America/Chicago’ for […]  instead in /var/www/999999.php on line 99

You can fix this on a per-script basis by adding:


to the script in question (or to a PHP include that is loaded earlier in the script) and this should fix the error for that particular script.

However, a more thorough solution is to define the timezone in your php.ini file. For example, on Gentoo your php.ini file may be located here:


and look for the section similar to:

; Defines the default timezone used by the date functions
date.timezone = ‘America/Chicago’

the “date.timezone” may be commented out with a “;” but you can simply remove the semicolon and then add the correct timezone. An Apache reboot may or may not be required after this point.

This should resolve your issue for ALL php scripts that you may run on that server.

More discussion on the topic:

Gentoo Forums :: View topic - apache / php error

Gentoo Forums :: View topic – apache / php error
Linux: phpinfo() system’s timezone error date.timezone

Linux: phpinfo() system’s timezone error date.timezone post: Explains: Linux Library / Dynamic Shared Object [ vdso ] Next post: Linux / UNIX: Software Update Vs Upgrade – What’s the Difference?
PHP: date_default_timezone_set - Manual

PHP: date_default_timezone_set – Manual (PHP 5 >= 5.1.0)date_default_timezone_set — Sets the default timezone used by all date/time functions in a script
WordPress › Support » Php 5.3.0 & WP 2.8 (It is not safe to rely on the system’s timezone)*** Warning: strtotime() [function.strtotime]: It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the…

PS and here is a list of all the PHP American timezone cities 🙂

America/Adak America/Anchorage America/Anguilla America/Antigua America/Araguaina
America/Argentina/Buenos_Aires America/Argentina/Catamarca America/Argentina/ComodRivadavia America/Argentina/Cordoba America/Argentina/Jujuy
America/Argentina/La_Rioja America/Argentina/Mendoza America/Argentina/Rio_Gallegos America/Argentina/Salta America/Argentina/San_Juan
America/Argentina/San_Luis America/Argentina/Tucuman America/Argentina/Ushuaia America/Aruba America/Asuncion
America/Atikokan America/Atka America/Bahia America/Bahia_Banderas America/Barbados
America/Belem America/Belize America/Blanc-Sablon America/Boa_Vista America/Bogota
America/Boise America/Buenos_Aires America/Cambridge_Bay America/Campo_Grande America/Cancun
America/Caracas America/Catamarca America/Cayenne America/Cayman America/Chicago
America/Chihuahua America/Coral_Harbour America/Cordoba America/Costa_Rica America/Cuiaba
America/Curacao America/Danmarkshavn America/Dawson America/Dawson_Creek America/Denver
America/Detroit America/Dominica America/Edmonton America/Eirunepe America/El_Salvador
America/Ensenada America/Fort_Wayne America/Fortaleza America/Glace_Bay America/Godthab
America/Goose_Bay America/Grand_Turk America/Grenada America/Guadeloupe America/Guatemala
America/Guayaquil America/Guyana America/Halifax America/Havana America/Hermosillo
America/Indiana/Indianapolis America/Indiana/Knox America/Indiana/Marengo America/Indiana/Petersburg America/Indiana/Tell_City
America/Indiana/Vevay America/Indiana/Vincennes America/Indiana/Winamac America/Indianapolis America/Inuvik
America/Iqaluit America/Jamaica America/Jujuy America/Juneau America/Kentucky/Louisville
America/Kentucky/Monticello America/Knox_IN America/Kralendijk America/La_Paz America/Lima
America/Los_Angeles America/Louisville America/Lower_Princes America/Maceio America/Managua
America/Manaus America/Marigot America/Martinique America/Matamoros America/Mazatlan
America/Mendoza America/Menominee America/Merida America/Metlakatla America/Mexico_City
America/Miquelon America/Moncton America/Monterrey America/Montevideo America/Montreal
America/Montserrat America/Nassau America/New_York America/Nipigon America/Nome
America/Noronha America/North_Dakota/Beulah America/North_Dakota/Center America/North_Dakota/New_Salem America/Ojinaga
America/Panama America/Pangnirtung America/Paramaribo America/Phoenix America/Port-au-Prince
America/Port_of_Spain America/Porto_Acre America/Porto_Velho America/Puerto_Rico America/Rainy_River
America/Rankin_Inlet America/Recife America/Regina America/Resolute America/Rio_Branco
America/Rosario America/Santa_Isabel America/Santarem America/Santiago America/Santo_Domingo
America/Sao_Paulo America/Scoresbysund America/Shiprock America/Sitka America/St_Barthelemy
America/St_Johns America/St_Kitts America/St_Lucia America/St_Thomas America/St_Vincent
America/Swift_Current America/Tegucigalpa America/Thule America/Thunder_Bay America/Tijuana
America/Toronto America/Tortola America/Vancouver America/Virgin America/Whitehorse
America/Winnipeg America/Yakutat America/Yellowknife


Leave a Reply

Your email address will not be published. Required fields are marked *