created_time = models.DateTimeField(auto_now_add=True, blank=True)
last_updated = models.DateTimeField(auto_now=True, blank=True)
NOTE: about timezone
There are 2 settings in settings.py
TIME_ZONE = 'Asia/Bangkok'
USE_TZ = False
if set like above, DateTimeField with auto_now and auto_now_add will use local time as indicated in
TIME_ZONE
, e.g. 17:00:00 (GMT+7:00)
however, if set
USE_TZ = True
, auto_now and auto_now_add will use UTC time, e.g. 10:00:00
ไม่มีความคิดเห็น:
แสดงความคิดเห็น