Tell me more ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I would like to know where does mysql get it current time. I am updating a table and using

update `table1` set `cola` = 1, `colb` =2 , `updated` = NOW();

the time is 2 hours early. the time on the server is completly different, so I'm a little confused...

I tried

 SELECT @@global.time_zone, @@session.time_zone;

but I get SYSTEM as result

share|improve this question

migrated from stackoverflow.com Oct 3 '12 at 19:52

3 Answers

Try to set time zone on your server: mysql> SET time_zone = '+/-xx:xx';

share|improve this answer
The query worked but what query displys the current clock? – devmonster Oct 2 '12 at 13:13
I'm not sure what exactly you asking me but, you can get time from server with now and compere this with your time,and then mysql> SET time_zone = '+/- difference'; – Zoran Marjanovic Oct 3 '12 at 10:07

Possible you find a solution for your need on this thread

When you are not able to set the system time zone by console, you should take a look at the function CONVERT_TZ() .... more informations you get by click the link above

share|improve this answer

To show used time_zone execute :

mysql> show variables like 'time_zone';
+---------------+--------+
| Variable_name | Value  |
+---------------+--------+
| time_zone     | SYSTEM |
+---------------+--------+
1 row in set (0.00 sec)

You said your time_zone variable is set to SYSTEM, so normally your system and MySQL have the same date.

Check your system date (on linux) :

root@myserv:~# date
mercredi 2 janvier 2013, 15:10:46 (UTC+0100)

Check your MySQL Server date :

mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2013-01-02 15:10:58 |
+---------------------+
1 row in set (0.00 sec)

If the both dates are not the same it's really strange :) if your system have a wrong date, update your system date, if you want to change just MySQL date try :

mysql> set global time_zone='+01:00'

I used '+01:00' because i live in Paris but you should adapt this from your local time zone.

Max.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.