Im using

$date = gmdate("Y-m-d H:i:s");

To give posts on my website timestamps.

The problem is, its one hour behind. Is this because gmdate doesnt account for daylight saving time? And if it is and I do H+1 then I shall haveto change it every 6 months shant I? That cant be right.. so err.. what am I doing wrong?

Yes I AM actually in a GMT timezone. ;p

    GMT is fixed. If you want PHP to take Daylight Saving into account then use date(). It can be customized in lots of ways...

      date.. soooo I can just do

      $date = date("Y-m-d H:i:s"); 
      

      with H+ (however many hours it is- i'll work it out in a sec) and thatll adjust automatically ?

      I cant believe gmdate doesnt. =/ Doesnt that make it an almost entirely pointless function??

        By default, date() will use whatever timezone is set on your server's clock. If the server automatically adjusts for Daylight Saving Time then you don't need to change anything. The "T" flag will make date() print out the current timezone, e.g.

        2006-06-05 18:30:17 BST

        gmdate() is a bit pointless for most purposes really, but oh well.

          Write a Reply...