Either I'm stupid, or something is wrong.
I have two SQL servers, one of which is located on my local computer (local time +2 GMT ), and the other somewhere else ( NOW() seems to return +8 GMT ), and I access it through phpMyAdmin. I have a table with a DATETIME column. I'm trying to
to save the current GMT / UTC time and then display it again, still as GMT / UTC.
I originally recorded DATE_SUB(NOW(), INTERVAL 8 HOUR) , which worked fine. However, then I read about UTC_TIMESTAMP() and liked it more, because it was shorter and MySQL manual even said:
"The current time zone does not affect the values ββdisplayed by functions such as UTC_TIMESTAMP () or the values ββin the DATE, TIME, or DATETIME columns."
So beautiful? Except not.
Suppose Current GMT is 2010-02-18 17:18:17 (I even double-checked it with someone in Britain).
In my local (+2) server , I get the following results for the following queries:
SELECT NOW(); 2010-02-18 19:18:17 SELECT UTC_TIMESTAMP(); 2010-02-18 17:18:17
In my online server, I get:
SELECT NOW(); 2010-02-19 01:18:17 SELECT UTC_TIMESTAMP(); 2010-02-19 07:18:17 (WHY?!)
Did I miss something?!
timezone mysql timestamp utc
Alex
source share