2013-02-26

At some point in time with the newer versions of PHP, a lot of you would see this warning spit out by your PHP installation every time you called a date related function: “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 ‘UTC’ for ‘Africa/Johannesburg’ instead”. What it is basically telling you is that you need to explicitly set the timezone which PHP is to use, instead of just letting it run with whatever the server was using as you used to do in the past. To do this you have two choices, which if you had bothered reading the warning message, would have been given to you on a platter. The first option you would use on a script by script basis, which of course doesn’t really make all that much sense. Basically, call the date_default_timezone_set() function and set it to a timezone string of your choice. The second option, and the one which makes the most sense is to set the default timezone in the php.ini configuration file itself, using the date.timezone declaration. In practice: ... date.timezone = 'Africa/Johannesburg' Nifty. Related Link: http://php.net/manual/en/function.date-default-timezone-set.php

Show more