SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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&rsquo;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\today.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

  2. #2
    SitePoint Mentor silver trophy
    Rubble's Avatar
    Join Date
    Dec 2005
    Location
    Cambridge, England
    Posts
    2,408
    Mentioned
    81 Post(s)
    Tagged
    3 Thread(s)
    I do not get that so it must be a server setup; try this:
    PHP Code:
    <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>

  3. #3
    SitePoint Wizard silver trophybronze trophy Stormrider's Avatar
    Join Date
    Sep 2006
    Location
    Nottingham, UK
    Posts
    3,133
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the replies, I'll go ahead and give both tips a try. -Ben


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •