python datetime.datetime 时间转换
2021-04-17 19:29
标签:int 时间 字符 查询 定时 day span 日期加减 lis 1、字符串转换为datetime.datetime: 输出:2020-07-09 18:21:17 2、tuple、list转换为datetime.datetime: 输出: 2020-07-10 09:40:47 3、日期加减 输出: 2020-07-14 11:34:47.671556 2020-07-14 12:34:47.671556 2020-07-15 11:34:47.671556 2020-07-21 11:34:47.671556 4、修改时间为指定时间(查询是从00:00:00开始查询) 输出: 2020-07-15 00:00:00 5、10 && 13位时间戳: 输出: 1594698366 1594698366000 1594345247 1594345247000 python datetime.datetime 时间转换 标签:int 时间 字符 查询 定时 day span 日期加减 lis 原文地址:https://www.cnblogs.com/wq-zhou/p/13298250.htmlprint(datetime.datetime.strptime("2020-07-09 18:21:17", "%Y-%m-%d %H:%M:%S"))
datetime_list = [2020, 7, 10, 9, 40, 47]
datetime_tuple = (2020, 7, 10, 9, 40, 47)
print(datetime.datetime(*datetime_list))
print(datetime.datetime(*datetime_tuple))
2020-07-10 09:40:47print(datetime.datetime.now())
print(datetime.datetime.now() + datetime.timedelta(hours=1))
print(datetime.datetime.now() + datetime.timedelta(days=1))
print(datetime.datetime.now() + datetime.timedelta(weeks=1))
print((datetime.datetime.now() + datetime.timedelta(days=1)).strftime("%Y-%m-%d 00:00:00"))
print(int(datetime.datetime.now().timestamp()))
print(int(datetime.datetime.now().timestamp())*1000)
print(int(datetime.datetime(2020, 7, 10, 9, 40, 47).timestamp()))
print(int(datetime.datetime(2020, 7, 10, 9, 40, 47).timestamp())*1000)
上一篇:lua 数组
文章标题:python datetime.datetime 时间转换
文章链接:http://soscw.com/index.php/essay/76111.html