Converting a Unix timestamp into a human format

Written by

in

No matter which calendar your culture subscribes to, doing “date math” is awkward. In the Gregorian calendar, the calendar used in the US, figuring out how many days are between November 27, 1962, and August 17, 2012 will require a lot of patience, a pencil, and possibly extra erasures.

With enough frustrated programmers, there is often a solution, and in this case, the concept of a Unix epoch was created. Just like any other calendar, its starting date is arbitrary, but significant to its domain. In this case, the date, or really a timestamp, chosen was the first moment of January 1st, 1970. This timestamp is expressed as zero and is known as the Unix Epoch, the beginning of measured time in Unix, measured as seconds since then, expressed as whole numbers. Before long, it became the standard for stating time in numeric format, regardless of which operating system you used or which language the software was written in.

In just about any programming language, there are functions for converting timestamps to human-readable formats, and vice versa, but sometimes the logic gets tricky with time zones, making the resulting timestamps tough to figure out.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *