The fundamentals of time

Time isn’t actually that hard—once you understand a handful of concepts.

The trouble is that most of us learn it backwards: API first. In Python that usually means the standard library’s datetime module, figured out by trial and error, without ever forming a clear picture of what a time value is supposed to represent. It’s the same way many people use str long before they’ve heard of Unicode: a rule of thumb like “just use UTF-8” carries you a long way—right up until something behaves strangely and you have no model to reason with.

“Just use UTC” is that kind of rule, and it fails the same way. The pages below cover the handful of ideas such rules paper over. They’re written to be read in order, starting with the most important distinction of all: exact time versus local time.

1. Exact time vs local time

A moment on the timeline, or a reading on a clock: not the same thing

Exact time vs local time
2. Timezones

The rules that connect the two—and what “timezone” actually means

Timezones
3. Ambiguity

When the clock says something twice, or skips it entirely

Ambiguity
4. Arithmetic

Why “a day later” and “24 hours later” are different questions

Arithmetic

Tip

Once you’re comfortable with the fundamentals, head to the guide to see how whenever puts them into practice.