Unix Timestamp Intuition

Let’s get a date and its corresponding unix timestamp.

dt=$(date --iso-8601=s)
echo "$dt --> $(date +%s --date=$dt)"
2022-04-07T11:28:04+02:00 --> 1649323684

The number 1649323684 is composed of 10 digits, each one representing a power of 10 for seconds, but what does that mean in human time?

position

pow(10)

seconds since 1970

approximate human time

1

9

1000000000

31 years

2

8

100000000

3 years

3

7

10000000

3 months

4

6

1000000

11 days

5

5

100000

a day

6

4

10000

2 hours

7

3

1000

16 minutes

8

2

100

a minute

9

1

10

10 seconds

10

0

1

a second

For example increasing the second digit from 6 to 7 moves the timestamp 3 years into the future:

$ date --utc --iso-8601=s --date=@1649323684
2022-04-07T09:28:04+00:00

$ date --utc --iso-8601=s --date=@1749323684
2025-06-07T19:14:44+00:00

Min & Max Timestamps with 10 Digits

$ date --utc --iso-8601=s --date=@0000000000
1970-01-01T01:00:00+00:00

$ date --utc --iso-8601=s --date=@9999999999
2286-11-20T17:46:39+00:00

Notes

Code

To generate the above table using humanize:

import humanize
import datetime as dt

DIGITS = 10

for pos in range(1, DIGITS+1):
    pow10 = DIGITS - pos
    total_s = DIGITS**pow10
    human = humanize.naturaldelta(total_s)
    print(','.join([str(x) for x in [pos, pow10, total_s, human]]))

This code is good enough for this simple one-off use-case. The Over-Engineer Software-Engineer in my mind says:

  • use functions!

  • use yield!

  • use csvwriter!

  • output at the end!

  • import structlog :D