I have a model called Vote with a date field:
date = models.DateTimeField(auto_now_add=True)
When I add an item, the date in MySQL is a UTC date, but I live in UTC + 2 time zone
I think I set the time zone correctly in settings.py :
TIME_ZONE = 'Europe/Paris'
Python uses the correct time zone:
>>> print datetime.datetime.now() 2013-07-03 09:05:04.474000
MySQL too:
> SELECT NOW( ) 2013-07-03 09:00:48
I can set the date attribute manually, it works, but I would like to know why auto_now_add returns the wrong date, although python and mysql use the correct time zone
thanks
python timezone django mysql datetime
Thomas K
source share