import datetime
now=datetime.datetime.now() #获取当前系统时间
now.hour #小时
now.minute #分
now.year #年
now.month #月
now.day #日
from datetime import datetime, date, timedelta
import time
now = date.today() + timedelta(days = -1)
month_first = date(now.year,now.month,1)
print(now)
print(month_first)
index_date= 1617206400
timeArray = time.localtime(index_date) # index_date / 1000#(13位时间戳)
otherStyletime = time.strftime("%Y-%m-%d %H:%M:%S", timeArray)#格式化日期
print(otherStyletime)
timeStamp = int(time.mktime(month_first.timetuple()))#时间转化为10位时间戳
print(timeStamp)
python获取系统时间
最新推荐文章于 2024-09-01 11:16:00 发布