| Bug #34584 | NOW() function returns time + 2 hours | ||
|---|---|---|---|
| Submitted: | 15 Feb 2008 10:36 | Modified: | 15 Feb 2008 15:29 |
| Reporter: | Sven Sandberg | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server: General | Severity: | S2 (Serious) |
| Version: | 5.1 | OS: | Linux |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | date, NOW, time, timezone | ||
[15 Feb 2008 12:18]
Susanne Ebrecht
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.
My tests:
uname -a
Linux ernie 2.6.22-14-generic #1 SMP Thu Jan 31 23:33:13 UTC 2008 x86_64 GNU/Linux
Ubuntu 7.10
mysql> select version()\G
*************************** 1. row ***************************
version(): 5.1.24-rc-debug
mysql> select now(), current_time(), curtime(), localtime(), sysdate(), utc_time()\G
*************************** 1. row ***************************
now(): 2008-02-15 13:18:14
current_time(): 13:18:14
curtime(): 13:18:14
localtime(): 2008-02-15 13:18:14
sysdate(): 2008-02-15 13:18:14
utc_time(): 12:18:14
$ date
Fr 15. Feb 13:18:16 CET 2008
[15 Feb 2008 13:13]
Sven Sandberg
I took a new clone of mysql-5.0 after I saw your comment above, and the error is still there:
mysql> select now(), current_time(), curtime(), localtime(), sysdate(), utc_time()\G
*************************** 1. row ***************************
now(): 2008-02-15 16:13:55
current_time(): 16:13:55
curtime(): 16:13:55
localtime(): 2008-02-15 16:13:55
sysdate(): 2008-02-15 16:13:55
utc_time(): 13:13:55
1 row in set (0.00 sec)
$ date
Fri Feb 15 13:14:07 UTC 2008
[15 Feb 2008 13:28]
Sven Sandberg
(Note: it showed UTC timezone in my last test because I had renamed /etc/localtime while debugging this.)
[15 Feb 2008 13:31]
Sven Sandberg
Adding this information: select version()\G *************************** 1. row *************************** version(): 5.1.24-rc-debug-log
[15 Feb 2008 15:29]
Sven Sandberg
Sorry, this is a feature of mysql-test-run, not a bug. It sets the timezone hard-coded to Moscow time to avoid having tests depending on the timezone.

Description: MySQL's time functions return the current system time, plus two hours: ---- In mysql ---- mysql> select now(), current_time(), curtime(), localtime(), sysdate(), utc_time()\G *************************** 1. row *************************** now(): 2008-02-15 13:23:42 current_time(): 13:23:42 curtime(): 13:23:42 localtime(): 2008-02-15 13:23:42 sysdate(): 2008-02-15 13:23:42 utc_time(): 10:23:42 ---- Six seconds later, in the shell ---- $ date Fri Feb 15 11:23:48 CET 2008 ---- My setup ---- I'm in Uppsala, time zone CET, during winter time, i.e., UTC + 1 hour. I tried various combinations of the following, but it did not change anything: - Modify the $TZ environment variable - Modify the $time_zone environment variable - Rename /etc/timezone - Rename /etc/localtime No other programs have had problems with time. Verified in a compiled mysql-5.1-new-rpl tree on two systems: - My laptop running Ubuntu 7.10, where uname -a says "Linux riska 2.6.22-14-generic #1 SMP Fri Feb 1 04:59:50 UTC 2008 i686 GNU/Linux". I do not have a mysql installation on this machine, only locally compiled trees (never did make install). - The replication machine, rpl-opt-a.mysql.com, where uname -a says "Linux dl145h.mysql.com 2.6.16-1.2069_FC4smp #1 SMP Tue Mar 28 12:48:20 EST 2006 x86_64 x86_64 x86_64 GNU/Linux". Please let me know if you need any more information. How to repeat: see above