UUIDs, Unix Time and ISO 8601
Level 5 · IDs, dates and patterns
An ID no other computer will make, a moment as one number, and a date written so it sorts. How UUIDs, Unix time and ISO 8601 work.
Course contentsLesson 10 of 11
Level 1 · Files and formats
Level 2 · Data formats
Level 3 · Config and docs files
Level 4 · Characters and escapes
Level 5 · IDs, dates and patterns
After this lesson you can
- Read the parts of a UUID
- Turn a Unix timestamp into a date
- Write a date in ISO 8601
12 mincovers 3 glossary entries
Worth reading first: Escapes, Base64, URL Encoding
How programs write down IDs and moments in time
A UUID is a 128-bit ID that no other computer will make, written as 32 hex digits in five groups. A Unix timestamp counts the seconds since midnight on 1 January 1970, in UTC. ISO 8601 writes a date year first, like 2026-03-07. All three let programs agree with no central list.
Any computer can make a UUID without asking anyone. The groups have 8, 4, 4, 4 and 12 digits. The first digit of the third group says the version. Version 4 is fully random, and the chance of two matching is tiny.
Version 7 starts with the time, so newer IDs sort after older ones. That makes them faster to look up in a database. Do not use a UUID as a secret, like in a reset link, because some versions can be guessed.
A Unix timestamp is one whole number, like 1700000000. It is the same in each time zone. Computers find it easy to store, compare and subtract. Some systems count in thousandths of a second, which adds three digits.
Old systems store it in 32 bits, which run out at 03:14:07 UTC on 19 January 2038. One second later, the count wraps and reads as a date in 1901. Newer systems use 64 bits, which last far longer than the sun.
ISO 8601 writes a date as year, month and day, like 2026-03-07. A time can follow after a T, like 2026-03-07T14:30:00. A Z at the end means UTC, and +01:00 means one hour ahead of it. Because the biggest part comes first, these dates sort in time order as plain text.
The common mistake is leaving off the Z or the offset. The time then has no zone, and each reader guesses its own. A meeting at 14:30 can land at three times in three offices.
$ uuidgen
4149014e-eabb-4fab-a179-5177233cc0e5
$ date -u -d @1700000000 '+%Y-%m-%dT%H:%M:%SZ'
2023-11-14T22:13:20ZWorked example
Emma's report is in the wrong order
Emma's report lists 30 sales by date, written as 7/3/2026. When she sorts them as text, 10/3 lands before 7/3.
She switches to ISO 8601, like 2026-03-07. Sorted as plain text, all 30 dates fall into the right order.
The words for this lesson3
Check yourself
Why do ISO 8601 dates sort correctly as plain text?
Finished this lesson?
Marking it complete also marks its 3 glossary entries learned, which updates your roadmap and your saved page. 0 are already marked.