一、查看當前時間
now函數
mysql> select now(); +---------------------+ | now() | +---------------------+ | 2016-04-29 22:04:42 | +---------------------+ 1 row in set (0.00 sec)
二、通過unix時間獲取字符串格式的時間
FROM_UNIXTIME函數
mysql> select FROM_UNIXTIME(1461938772); +---------------------------+ | FROM_UNIXTIME(1461938772) | +---------------------------+ | 2016-04-29 22:06:12 | +---------------------------+ 1 row in set (0.17 sec)
應用:
select FROM_UNIXTIME(clock) as date, userid, action, ip, resourcename from auditlog where clock> %s;" % yest_clock
注意:linux中獲取當前unix時間 date +%s
三、