SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help on Date and Time

    hi! i'm new to php. what i'm trying to do is to print a date in which i saved it through session. my script is "gmdate("h:i:s")" but it keeps on displaying differently as what i am seeing on my pc's time clock. (e.g. my web displays 5:30:50 am and my pc's time is 1:30 pm) pls. help me! and thanks in advance!

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    gmdate() will display a time in GMT

    date() will display a time in the servers time zone

    if your server is not in your timezone, you need to compensate for it.
    PHP Code:
    // set this to the correct timezone offset
    $gmt_offset = -6;
    $corrected_timestamp time() + 3600 $gmt_offset;
    echo 
    gmdate("h:i:s"$corrected_timestamp); 
    http://wwp.greenwichmeantime.com/

  3. #3
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks a lot sir!


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
  •