Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql from_timestamp(0) does not match my current time

Tags:

timezone

mysql

My timezone is UTC+8, but when I run

mysql> select from_unixtime(0);
+---------------------+
| from_unixtime(0)    |
+---------------------+
| 1970-01-01 07:30:00 |
+---------------------+

I got "1970-01-01 07:30:00" instead of "1970-01-01 08:00:00".

I ran:

show variables like "%time_zone%";  

Then I got:

system_time_zone    +08  
time_zone           SYSTEM  
like image 398
Hilda Chang Avatar asked Nov 08 '22 20:11

Hilda Chang


1 Answers

Assuming you are in Singapore, the timezone in the area in 1970 was GMT +7.5. It wasn't until 1982, that the present value of GMT +8 started to be used.

Period in use   Time offset from GMT    Reference Meridian  Name of Time

...           1905 May 31   + 6hr 55m 25s   103 51 16 E Singapore Mean Time
1905 Jun 01 - 1932 Dec 31   + 7hr 00m 00s   105 00 00 E Standard Zone Time
1933 Jan 01 - 1941 Aug 31   + 7hr 20m 00s   110 00 00 E Daylight Saving Time    
1941 Sep 01 - 1942 Feb 15   + 7hr 30m 00s   112 30 00 E Daylight Saving Time
1942 Feb 16 - 1945 Sep 12   + 9hr 00m 00s   135 00 00 E Tokyo Standard Time @
1945 Sep 13 - 1981 Dec 31   + 7hr 30m 00s   112 30 00 E DST/MST/SST # @
1982 Jan 01 - Present       + 8hr 00m 00s   120 00 00 E Singapore Standard Time

http://www.math.nus.edu.sg/aslaksen/teaching/timezone.html

like image 71
Cyril Graze Avatar answered Nov 14 '22 21:11

Cyril Graze