How to SELECT UTC_TIMESTAMP () return -10: 00 UTC?

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?!

+6
timezone mysql timestamp utc
source share
1 answer

Probably because the clock on the Internet server is incorrect?

Try the following:

 SELECT @@system_time_zone, NOW(), UTC_TIMESTAMP() 

and look in which zone he is returning to and if the difference is appropriate.

+10
source share

All Articles