MySQL(Unix时间戳、日期)转换函数
2016-05-30 14:46 abce 阅读(1589) 评论(0) 编辑 收藏 举报unix_timestamp()
mysql> select unix_timestamp(); +------------------+ | unix_timestamp() | +------------------+ | 1464590043 | +------------------+
unix_timestamp(date)
mysql> select unix_timestamp('2016-05-30'); +------------------------------+ | unix_timestamp('2016-05-30') | +------------------------------+ | 1464537600 | +------------------------------+ mysql> select unix_timestamp('2016-05-30 14:35:21'); +---------------------------------------+ | unix_timestamp('2016-05-30 14:35:21') | +---------------------------------------+ | 1464590121 | +---------------------------------------+
from_unixtime(unix_timestamp)
mysql> select from_unixtime(1464590043); +---------------------------+ | from_unixtime(1464590043) | +---------------------------+ | 2016-05-30 14:34:03 | +---------------------------+
from_unixtime(unix_timestamp,format)
mysql> select from_unixtime(1464590043, '%Y %D %M %h:%i:%s %x'); +---------------------------------------------------+ | from_unixtime(1464590043, '%Y %D %M %h:%i:%s %x') | +---------------------------------------------------+ | 2016 30th May 02:34:03 2016 | +---------------------------------------------------+