python日期,时间函数

获取当前格式化时间:

now_time = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())

 

获取当前时间戳:

now_timestamp = int(time.time())
格式更改:先转换为时间数组
a = "2013-10-10 23:40:00",
timeArray = time.strptime(a, "%Y-%m-%d %H:%M:%S")
timestamp = int(time.mktime(timeArray))
otherStyleTime = time.strftime("%Y/%m/%d %H:%M:%S", timeArray)
otherStyleTime = "2013/10/10 23:40:00"
posted @ 2017-01-21 15:59  知行Lee  阅读(266)  评论(0编辑  收藏  举报