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())
版权声明:本文为zy0517原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。