I have an issue with a saved object randomly changing timezone.
My django application is on an ubuntu webserver, which is synchronised using ntp.
In my django settings file I have TIME_ZONE = 'Europe/London'
The object I am creating uses myObject.timestamp=datetime.datetime.now() and is then saved.
For some reason, I am finding that occasionally the timestamp recorded is -6 hours from what it should be (i.e. as if the server was reverting to default timezone settings).
This only ever seems to happen on a Monday morning between about 4 and 6 am. I have not found any scheduled tasks that correspond to this.
e.g. this morning the following objects were created:
time_created/timestamp_recorded
05:02/05:02
05:03/23:03
05:04/05:04
05:05/23:05
05:06/23:06
05:07/05:07
05:08/23:08
05:09/05:09
…and so on until 05:45 from when all objects had the right timestamp.
any ideas about where I should look for possible causes?
I found the answer – see http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Timezone_and_Locale_Settings
Basically a secondary application was also running under wsgi, and this other application made no use of datetime. As such, I had not altered its timezone settings from default. Whenever this other application ran, it would reset the environment to the default timezone.
Hence when my core application ran, it would simultaneously use the wrong locale, but then also reset the environment to the right one, leading to the intermittent fault.