Warning message with first PHP script

Hello all, just purchased my copy of ‘Build Your Own Database…Using PHP & MYSQL’ and tried my first script with strange results.

As the book suggested, I typed the following:

<body>
<p>Today’s date (according to this web server) is
<?php
echo date(‘1, F dS Y.’);
?>
</p>
</body>

Here is what my browser came back with:

Today’s date (according to this web service) is
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 ‘America/Denver’ for ‘-6.0/DST’ instead in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\ oday.php on line 13
1, May 26th 2011.

The first line and last line seem to have worked somewhat, however the Warning block in the middle is not what I hoped for. Does anyone have an idea on how I can get rid of such Warning messages from my script. Thank you again for taking time to read my post. -Ben

I do not get that so it must be a server setup; try this:


<body>
<p>Today&rsquo;s date (according to this web server) is
<?php
// Change the country city to what you need see
// http://www.php.net/manual/en/timezones.php
date_default_timezone_set('Europe/London');
echo date('1, F dS Y.');
?>
</p>
</body>

First, change the 1 for an l (lowercase L).

Secondly, you’ll need to set the timezone in the php.ini file - where this is depends on your setup, but you can find the path to it by running phpinfo(); in a php script and looking for the ‘loaded configuration file’ or something.

Thank you for the replies, I’ll go ahead and give both tips a try. -Ben :slight_smile: