Server GMT time problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Fareast Adam
    New Member
    • Feb 2007
    • 51

    Server GMT time problem

    I've a field in a table that datatype's type datetime. Here i want to get current server GMT time before insert into db. Any idea why this code always give me result in am although the present time is pm?

    Sample result: 18/09/2007 01:29:04 am

    here the php code;

    [PHP]$time = gmdate('Y-m-d h:i:s', mktime(gmdate(' GMT') + 8));[/PHP]
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    Do not post Questions in the Article Sections. [Plzzzzzzzzzzz]

    Comment

    • ak1dnar
      Recognized Expert Top Contributor
      • Jan 2007
      • 1584

      #3
      Originally posted by Fareast Adam
      I've a field in a table that datatype's type datetime. Here i want to get current server GMT time before insert into db. Any idea why this code always give me result in am although the present time is pm?

      Sample result: 18/09/2007 01:29:04 am

      here the php code;

      [PHP]$time = gmdate('Y-m-d h:i:s', mktime(gmdate(' GMT') + 8));[/PHP]
      Are you using your local, machine as your server? or where is your server located? You know what is gmdate(), right?

      Comment

      • Fareast Adam
        New Member
        • Feb 2007
        • 51

        #4
        Ya i used localhost as my server. Sorry for any mistaken!

        Comment

        • Fareast Adam
          New Member
          • Feb 2007
          • 51

          #5
          I want to get present Malaysia GMT time (GMT + 08:00) within localhost. But i got the unexpected result, where all the result display am althought currently is pm in Malaysia when i retrieve it from database. Am i wrong on way?

          Comment

          • kovik
            Recognized Expert Top Contributor
            • Jun 2007
            • 1044

            #6
            I'm not to sure what you are doing with mktime(), gmdate(), or the +8, but I'm fairly sure you didn't read the documentation very well. Don't worry... I'm feeling nice today. Try this (not tested):

            [php]gmdate('Y-m-d H:i:s', strtotime('+8 hours'));[/php]

            Just so you know, strtotime() is awesome. :P

            Comment

            Working...