概述
times = datetime.datetime.today()
当天
month_end = datetime.datetime(times.year, times.month, times.day)
昨天
month_yesterday = month_end + datetime.timedelta(days=-1)
yesterday = month_yesterday.day
yestermonth = month_yesterday.month
yesteryear = month_yesterday.year
这月1号
startTime=str(int(time.mktime(time.strptime(’{}-{}-1 0:0:0’.format(yesteryear,yestermonth),’%Y-%m-%d %H:%M:%S’))))
昨天
endTime=str(int(time.mktime(time.strptime(’{}-{}-{} 23:59:59’.format(yesteryear,yestermonth,yesterday),’%Y-%m-%d %H:%M:%S’))))
这月第一天
month_strat = datetime.datetime(month_yesterday.year,month_yesterday.month, 1)
上月末
last_month_end = month_strat + datetime.timedelta(days=-1)
##上月昨天
last_month_yesterday = month_yesterday- relativedelta(months=+1)
上月1号
last_startTime=str(int(time.mktime(time.strptime(’{}-{}-1 0:0:0’.format(last_month_end.year,last_month_end.month),’%Y-%m-%d %H:%M:%S’))))
上月昨天
last_endTime=str(int(time.mktime(time.strptime(’{}-{}-{} 23:59:59’.format(last_month_yesterday.year,last_month_yesterday.month,last_month_yesterday.day),’%Y-%m-%d %H:%M:%S’))))
上月末
last_Time=str(int(time.mktime(time.strptime(’{}-{}-{} 23:59:59’.format(last_month_end.year,last_month_end.month,last_month_end.day),’%Y-%m-%d %H:%M:%S’))))
最后
以上就是纯真翅膀为你收集整理的python--时间的全部内容,希望文章能够帮你解决python--时间所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复