如何将当年1月1日转换为纪元?
可以使用UNIX_TIMESTAMP()函数来完成此操作,如下所示:
mysql> Select UNIX_TIMESTAMP(CONCAT(YEAR(CURDATE()),'-01-01')); +--------------------------------------------------+ | UNIX_TIMESTAMP(CONCAT(YEAR(CURDATE()),'-01-01')) | +--------------------------------------------------+ | 1483209000 | +--------------------------------------------------+ 1 row in set (0.03 sec)
可以通过以下查询进行验证-
mysql> Select FROM_UNIXTIME(1483209000); +---------------------------+ | FROM_UNIXTIME(1483209000) | +---------------------------+ | 2017-01-01 00:00:00 | +---------------------------+ 1 row in set (0.02 sec)