Main Content

What and why for the epoch

Archive - Originally posted on "The Horse's Mouth" - 2005-03-08 17:57:54 - Graham Ellis

The Epoch occurred on 1st January 1970 ... at midnight, at the start of the day, GMT. It's an important concept in many programming languages, which work with times and dates before and after the epoch - it means that you can compare dates and times easily, even where month ends and different timezones are involved. It's a pity that "now" in epoch seconds is displayed as a somewhat meaningless 1110304887 whereas you might prefer it to be displayed in a format such as Tue, 8 Mar 2005 10:01:27 -0800. The Perl language includes converters to translate between Epoch seconds and "human" time, as do PHP, Python, and Tcl/Tk - and they provide a powerful mechanism to calculate with times which otherwise would be an awkward mixture of modulo 7, 24, 52, 60 and 365 arithmetic.

Computer systems that run with 32 bit addressing (with one bit reserved for a sign) will "run out" of epoch seconds in the year 2038; perhaps that will be our next big "year 2K" issue. More likely, 64 bit systems will be in use throughout by then and the issue won't be an issue.

As a footnote, not all software uses epoch seconds. The software that we use for our internal diary system (not something we wrote ourselves) uses days from 1st January 0 - the year zero.