PostgreSQL – Handling the Unix Epoch Problem

dbmspostgresql

I was wondering if Postgres will be handling the unix epoch problem coming in 2038? I have read about this and am wondering.

It's about a productivity thing obviously because it is so far away, but I am curious.

Best Answer

If you look at https://www.postgresql.org/docs/11/functions-datetime.html in the documentation it displays data about the to_timestamp function that returns a timestamp with time zone value from an epoch value. Complete description is: "Convert Unix epoch (seconds since 1970-01-01 00:00:00+00) to timestamp"

The input type of the function is double precision.

From https://www.postgresql.org/docs/11/datatype-numeric.html you can see that double precision is defined as 8 bytes with 15 decimal digits precision. A little down below you can read:

The double precision type typically has a range of around 1E-307 to 1E+308 with a precision of at least 15 digits.

So 1E+308 seconds after 1970-01-01 should carry you far after 2038...

In fact if you look at https://wiki.postgresql.org/wiki/TodoDone84, which lists all features that have been done in PostgreSQL 8.4 you can see:

Completed item: Extend timezone code to allow 64-bit values so we can represent years beyond 2038