python datetime时区 timedelta

weednoah

关注

阅读 116

2022-06-20

#!/usr/bin/python
# -*- coding: utf8 -*-
from datetime import datetime, timedelta
now = datetime.now() # current date and time
now_up = now - timedelta(days=5)
now_up = now_up.strftime("%Y-%m-%dT%H:%M:%S+08:00")
date_time = now.strftime("%Y-%m-%dT%H:%M:%S+08:00")

start_time = str(now_up)
end_time = str(date_time)
print(start_time)
print(end_time)


相关推荐

精彩评论(0)

0 0 举报