First PHP script error

I get this error on local server
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/New_York’ for ‘-4.0/DST’ instead in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ oday.php on line 13
Saturday, June 08th 2013.

with this very first script

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"      
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">      
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">      
  <head>      
    <title>Today&rsquo;s Date</title>      
    <meta http-equiv="content-type"      
        content="text/html; charset=utf-8"/>      
  </head>      
  <body>      
    <p>Today&rsquo;s date (according to this web server) is      
      <?php      
      
      echo date('l, F dS Y.');      
      
      ?>      
    </p>      
  </body>      
</html>

Actually the message you received is a warning which is determined by your error_reporting() status.

Take a look at the Php Manual site and scroll down to Section on Examples

#“http://php.net/manual/en/function.date.php



date_default_timezone_set('UTC');


Great, thanks!

Better would be to pick one of the supported timezones and enter it in your php.ini, e.g.,


date.timezone = Europe/Amsteram

so it applies server wide and you don’t have to set it over and over for every script/website you write :slight_smile: