Skrevet av Emne: MySQL: datetime column uses correct timezone, NOW() does not  (Lest 4375 ganger)

ATC

  • Gjest
  • [applaud]0
  • [smite]0
  • When inserting data into a table that contains a 'datetime' type column, the timestamp is stored in the same timezone as the MySQL server is configured with.

    Unfortunately, when trying to query the same table using timestamps based on the NOW() function, I get the incorrect data because NOW() always seems to return the present time in UTC. How can I fix this?



    ATC

    • Gjest
  • [applaud]0
  • [smite]0
  • Use the following MySQL-specific command:
    SET SESSION time_zone = '+1:00'

    +1:00 corresponds to CET, replace with your own timezone.

    You may have to adjust for Daylight Saving Time, I really don't know...