Page 1 of 1

Mac Upgrade Breaks a simple code

Posted: Mon Mar 29, 2010 4:00 pm
by RobertVJ
I have used this simple code to output date time on a web page

Code: Select all

$date_time = strtotime("$test hour");
echo date("l - M j, Y - g:i A", $date_time);
Note that the test variable is set to 0 in this case. I use the local Apache server on my Mac to test changes and then FTP changes to the "live server".

Today I updated from OSX 10.5.8 to 10.6.3

While checking things out after the update the local server gives me this
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 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. /Sites/home.php on line 78

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. /Sites/home.php on line 79
I have been Googling and have no clue what is going on. It is just a simple time-stamp for the page; I am a php novice and tend to use Perl.

Thanks

Re: Mac Upgrade Breaks a simple code

Posted: Mon Mar 29, 2010 4:52 pm
by requinix
PHP doesn't know which timezone you want to use.

Code: Select all

date_default_timezone_set("Wherever/You_Are");
$date_time = strtotime("$test hour");
echo date("l - M j, Y - g:i A", $date_time);

Re: Mac Upgrade Breaks a simple code

Posted: Mon Mar 29, 2010 4:58 pm
by RobertVJ
I solved the problem. I needed to un-comment and set the value of date.timezone. Also the php.ini file didn't exit. There was a php.ini.default which I had to duplicate and rename it without the default. The default must be the template.