Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Dec 2007
    Posts
    269
    Thanks
    28
    Thanked 0 Times in 0 Posts

    date time problem

    PHP Code:
    echo date("H:i:s",$_SERVER['REQUEST_TIME']); // 17:30 
    but my computer time is 18:30 . why result of code is wrong ?

  • #2
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,447
    Thanks
    71
    Thanked 102 Times in 101 Posts
    Is it a private server or shared server? Because if you request the server time, it's going to be the time where the server is located. Such as I live in Virginia and my server is in another timezone, so it's a one hour difference.
    Been a sign maker for 7 years. My business:
    American Made Signs

  • #3
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,500
    Thanks
    8
    Thanked 1,089 Times in 1,080 Posts
    You can specify the timezone you want at the beginning of your script.
    The rest of the script will then use your timezone for all date and time calculations.

    Example:

    <?php
    date_default_timezone_set('America/Los_Angeles');

    Here is a list of valid city names:
    http://www.php.net/manual/en/timezones.php

    Pick the city that is in your timezone.

    And this is nice because it automatically adjusts standard and daylight savings times.


  •  

    Posting Permissions

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