SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry convert the time zones using PHP?

    hi all,
    How can we convert the time zones using PHP?

    Thanks in advance

  2. #2
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $timezone = -5; //(GMT -5:00) EST (U.S. & Canada)
    $date=gmdate("Y-m-d", time() + 3600*($timezone+date("I")));
    Try this
    Barbara

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks
    suppose if i want to convert other GMT i have to assign to $timezone

    what about time?

    it displays just date.

  4. #4
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    //for date and time as well
    $date=gmdate("Y-m-d H:i:s", time() + 3600*($timezone+date("I")));
    //for date
    $date=gmdate("Y-m-d H:i:s", time() + 3600*($timezone+date("I")));
    //for time
    $date=gmdate("H:i:s", time() + 3600*($timezone+date("I")));
    Try any of the above for date,time or for both
    Barbara

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2007
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $date=gmdate("H:i:s", time() + 3600*($timezone+date("I")));

    I am not getting what is the use of 3600 here

    can u explian?


    Thanx

  6. #6
    SitePoint Evangelist barbara1712's Avatar
    Join Date
    Apr 2007
    Location
    India
    Posts
    509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Difference is for the time
    Try this
    $date=gmdate("H:i:s", time() + 3600*($timezone+date("I")));

    And try this
    $date=gmdate("H:i:s", time() + ($timezone+date("I")));

    You will come to know the difference + explanation.
    Barbara


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
  •