Take the 2-minute tour ×

Either I'm being stupid or something's wrong here.

I have two SQL Servers, the one is on my local machine (local time +2 GMT) and the other is somewhere else (NOW() seems to return +8 GMT)and I access it through phpMyAdmin. I have a table that has a DATETIME column. I'm trying

to store the current GMT/UTC time and then display it again, still as GMT/UTC time.

Originally I stored DATE_SUB(NOW(), INTERVAL 8 HOUR) which worked just fine. However, then I read about UTC_TIMESTAMP() and liked it more, as it was shorter and the MySQL manual even said :

"The current time zone setting does not affect values displayed by functions such as UTC_TIMESTAMP() or values in DATE, TIME, or DATETIME columns."

So perfect right? Except no.

Let's assume Current GMT is 2010-02-18 17:18:17 (I even double checked it with someone in Britain).

On 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

On my online server I get:

SELECT NOW(); 2010-02-19 01:18:17

SELECT UTC_TIMESTAMP(); 2010-02-19 07:18:17 (WHY?!)

Am I missing something?!

share|improve this question
i m suffering with same issue. –  diEcho Jul 3 '12 at 8:42

1 Answer 1

up vote 3 down vote accepted

Probably because the clock are wrong on the online server?

Try running this:

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

and see which zone does it return and does it match the difference.

share|improve this answer
@@system_time_zone NOW() UTC_TIMESTAMP() CST 2010-02-19 01:35:30 2010-02-19 07:35:30 So, if I'm understanding this right, the server says it's CST (-6) and it's set to 1:35am, so SQL's saying well then add 6 to get to UTC... BAH! How frustrating. Thanks for clearing it up, I thought I was doing something wrong it's been driving me insane. –  Alex Feb 18 '10 at 17:39
Why is that frustrating? NOW() is the current time after timezone takes effect, so the functions are doing their job perfectly no? –  deed02392 Jul 18 '13 at 17:33

Your Answer


