您的位置:首页 > 编程语言 > Python开发

python日期,时间函数

2017-01-21 15:59 232 查看
获取当前格式化时间:

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"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: