首页 > 编程语言 > 详细

python 日期时间处理 常用方法

时间:2019-07-18 19:53:31      阅读:70      评论:0      收藏:0      [点我收藏+]

datetime 转字符串

create_on.strftime(‘%Y-%m-%d %H:%M:%S‘)

字符串转datetime

collect_on = datetime.datetime.strptime(collect_on_str, ‘%Y%m%d%H%M%S‘)

datetime转时间戳

time.mktime(create_on.timetuple())

时间戳转datetime

req_datetime = datetime.datetime.fromtimestamp(timestamp)

计算时间差

time_delta = (collect_on - interval_datetime).seconds

时间差转datetime

interval_group_end = interval_group_start + datetime.timedelta(seconds=duration)

python 日期时间处理 常用方法

原文:https://www.cnblogs.com/van28/p/11209072.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!