SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    PHP Developer W1LL's Avatar
    Join Date
    Apr 2001
    Location
    Leicester, UK
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Display correct time...?

    When I use the following:
    Code:
    date("H:i");
    it displays the time in EST, even though I am in GMT timezone. Is there anyway to display the time correct to the timezone someone is in? For instance, if I am in England, it will display the GMT time, or in Florida the EST time.

    - Will

  2. #2
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what you're getting is the SERVER time since that is where the script is being parsed. What you could do is have the user enter his timezone (say EST is GMT -5) and echo back a result like that) or actually use DHTML (not preferred by me), to calculate the browsers time.

    Sketch
    Aaron Brazell
    Technosailor



  3. #3
    PHP Developer W1LL's Avatar
    Join Date
    Apr 2001
    Location
    Leicester, UK
    Posts
    459
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks dude, I'll just stick with what I've got...
    Code:
    <?php
      $TimeDate = date("H:i T (\G\M\T O), d M Y");
      echo($TimeDate);
    ?>
    - Will

  4. #4
    Making a better wheel silver trophy DR_LaRRY_PEpPeR's Avatar
    Join Date
    Jul 2001
    Location
    Missouri
    Posts
    3,428
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you want GMT time, why not use gmdate() instead?

    PHP Code:
    echo gmdate('H:i'); 
    - Matt ** Ignore old signature for now... **
    Dr.BB - Highly optimized to be 2-3x faster than the "Big 3."
    "Do not enclose numeric values in quotes -- that is very non-standard and will only work on MySQL." - MattR


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
  •