一、查看当前时间
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
三、
本文出自 “崔德华运维打工从业路” 博客,请务必保留此出处http://cuidehua.blog.51cto.com/5449828/1769120
原文:http://cuidehua.blog.51cto.com/5449828/1769120