下面对mysql时间和日期处理做下总结
-
获取当前日期+时间函数now # =>python time.strftime("%Y-%y-%d %H:%M:%S")
1select now(); 2 3# | 2013-11-23 09:58:01 | -
获取当前日期函数curdate # =>python time.strftime("%Y-%y-%d")
1select curdate(); 2 3# | 2013-11-23 | -
获取当前时间函数curtime # =>python time.strftime("%X")
1select curtime(); 2 3# | 09:58:48 | -
获取当前UTC时间函数utc_timestamp = utc_date + utc_time
# 我国在东八区, 所以 本地时间=UTC时间+8 -
获取当前UNIX时间戳函数 unix_timestamp # => python time.time()
1select unix_timestamp(); 2 3# | 1385171950 |
暂时写这么多,其实也用不到复杂的处理,大多都是用 now 和 unix_timestamp来存储当前时间,复杂的处理交给程序吧.