datetime模块

datetime模块(Django中settings配置时区)

settings中配置上海时区

复制代码
# TIME_ZONE = 'UTC'
TIME_ZONE = 'Asia/Shanghai'

USE_I18N = True

USE_L10N = True

USE_TZ = False
复制代码

datetime模块

复制代码
import datetime
datetime.date   : "年月日"

datetime.time   : "时分秒"

datetime.datetime:"年月日 时分秒"

datetime.timedelta:"构建时间对象"  可以与其它datetime对象加减

print(datetime.datetime.now())  # 2018-02-08 11:44:02.382526
date_obj=datetime.datetime.now()
print(date_obj.year)
print(date_obj.month)
print(date_obj.day)
print(date_obj.second)
print(date_obj.hour)
print(date_obj.weekday())
posted @ 2018-03-02 18:49  邯城吴彦祖  阅读(119)  评论(0编辑  收藏  举报