Bug #72761 MySQL 5.6 FROM_UNIXTIME function returns different result than 5.5
Description:
1) In MySQL 5.6, FROM_UNIXTIME function returns fraction part which is not described in "data and time functions" section at the reference manual. MySQL 5.5 does not return.
http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_from-unixtime
Returns a representation of the unix_timestamp argument as a value in 'YYYY-MM-DD HH:MM:SS' or YYYYMMDDHHMMSS format, depending on whether the function is used in a string or numeric context.
2) In MySQL 5.6, FROM_UNIXTIME function with format '%s' returns floored value. MySQL 5.5 returns rounded value.
How to repeat:
MySQL 5.5.30:
mysql> select time,time/1000000, time div 1000000,from_unixtime(time/1000000),from_unixtime(time div 1000000),from_unixtime(time/1000000,'%Y-%m-%d %H:%i:%s') from (select 1398561576624099 as time)x\G
*************************** 1. row ***************************
time: 1398561576624099
time/1000000: 1398561576.6241
time div 1000000: 1398561576
from_unixtime(time/1000000): 2014-04-27 10:19:37
from_unixtime(time div 1000000): 2014-04-27 10:19:36
from_unixtime(time/1000000,'%Y-%m-%d %H:%i:%s'): 2014-04-27 10:19:37
1 row in set (0.00 sec)
MySQL 5.6.17:
mysql> select time,time/1000000, time div 1000000,from_unixtime(time/1000000),from_unixtime(time div 1000000),from_unixtime(time/1000000,'%Y-%m-%d %H:%i:%s') from (select 1398561576624099 as time)x\G
*************************** 1. row ***************************
time: 1398561576624099
time/1000000: 1398561576.6241
time div 1000000: 1398561576
from_unixtime(time/1000000): 2014-04-27 10:19:36.6240
from_unixtime(time div 1000000): 2014-04-27 10:19:36
from_unixtime(time/1000000,'%Y-%m-%d %H:%i:%s'): 2014-04-27 10:19:36
1 row in set (0.00 sec)
Suggested fix:
If you would change the function behavior, please describe that in documentation.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.049 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.