Time zones… If you do
datatime.datetime.now() you’ll get a date+time
without timezone information. You can get different results on your laptop
(set to local time) and a server (that might be set to UTC).
You can use
datetime.datetime.utcnow() that returns UTC
time. But… without a timezone attached. Best is to request the time in a
There are gotchas regarding time. Check your time only once in a calculation. If you call .utcnow() multiple times, you can get different dates when your code runs around 0:00.
time.time(): if the “ntp” daemon adjusts your system clock in
the mean time you get weird results. For that, there is
The original source for all time zone information is the time zone database (tzdata). You can download it and look at all the files per timezone. Interesting reading! Look at Istanbul’s timezone. Daylight savings time being delayed by a day in a specific year because of a nationwide school exam. It was anounced a few weeks before. That’s all in the time zone database.
So if you make a Docker now and still use it in two years’ time, you might run into problems because summer time might have been abolished by the EU by then. So make sure you keep your time zone libary up to date.
My name is Reinout van Rees and I work a lot with Python (programming language) and Django (website framework). I live in The Netherlands and I'm happily married to Annie van Rees-Kooiman.
Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):