Bug #51918 UNIX_TIMESTAMP and FROM_UNIXTIME functions

Submitted: 10 Mar 2010 15:25 Modified: 12 Mar 2010 8:06
Reporter: Daniel Dinnie Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: General Severity:S1 (Critical)
Version:5.1.41 OS:Windows (XP)
Assigned to: CPU Architecture:Any
Tags: from_unixtime, unix_timestamp

[10 Mar 2010 15:25] Daniel Dinnie
Description:
I found something strange with FROM_UNIXTIME function.
This function is used to change a unix time stamp into a date.

How to repeat:
I did the following query on my server

SELECT FROM_UNIXTIME(1268006400) , FROM_UNIXTIME(1268006424);

and got the following results

2010-03-08 01:59:36, 2010-03-08 02:00:00

If I work it out manually, those values are wrong.
They are out by 24 seconds.
I confirmed this on another site
http://www.onlineconversion.com/unix_time.htm

Suggested fix:
No suggestion
[10 Mar 2010 15:36] Valeriy Kravchuk
Please, check with a newer version, 5.1.44. Look:

mysql> SELECT FROM_UNIXTIME(1268006400) , FROM_UNIXTIME(1268006424);
+---------------------------+---------------------------+
| FROM_UNIXTIME(1268006400) | FROM_UNIXTIME(1268006424) |
+---------------------------+---------------------------+
| 2010-03-08 02:00:00       | 2010-03-08 02:00:24       |
+---------------------------+---------------------------+
1 row in set (0.00 sec)

mysql> select version();
+--------------+
| version()    |
+--------------+
| 5.1.45-debug |
+--------------+
1 row in set (0.00 sec)
[12 Mar 2010 7:13] Daniel Dinnie
Hi

I have installed MySQL 5.1.44 and I tried the queries again, and got the correct results.

Thanks
[12 Mar 2010 8:06] Valeriy Kravchuk
Not repeatable with 5.1.44.
[3 Apr 2010 18:04] Michal Vrchota
I had the same issue on windows platform. Upgrade to newer version helped. This bug is not excusable in production environment...
[6 Apr 2010 17:02] Michal Vrchota
The bug is still there. I have reported this bug separatly
http://bugs.mysql.com/bug.php?id=52624
[17 Jul 2020 10:56] rsneha rani
I found this site : https://www.easyunitconverter.com/unix-epoch-time-converter

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.