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.
Some other articles
Y115 - Additional Python Facilities Some gems from Intermediate Python Command line parameter handling in Python via the argparse module Json load from URL, recursive display, Python 3.4 Running an operating system command from your Python program - the new way with the subprocess module Json is the new marshall, pickle and cPickle / Python Python - an interesting application Handling JSON in Python (and a csv, marshall and pickle comparison) JSON from Python - first principles, easy example Teaching dilemma - old tricks and techniques, or recent enhancements? A demonstration of how many Python facilities work together Python regular expressions - repeating, splitting, lookahead and lookbehind Joining a MySQL table from within a Python program Factory methods and SqLite in use in a Python teaching example Running operating system commands from your Python program Python decorators - your own, staticmethod and classmethod Model - View - Controller demo, Sqlite - Python 3 - Qt4 Connecting Python to sqlite and MySQL databases Regular Expressions in Python Python - what is going on around me? Python - how it saves on compile time Serialization - storing and reloading objects Testing code in Python - doctest, unittest and others Python Regular Expressions A series of tyre damages Ignore case in Regular Expression Regular expressions made easy - building from components Turning objects into something you can store - Pickling (Python) Buffering output - why it is done and issues raised in Tcl, Perl, Python and PHP Sending an email from Python Python - listing out the contents of all variables Python 3000 - the next generation Keeping your regular expressions simple Python to MySQL Splitting the difference This article Examples - Gadfly, NI Number, and Tcl to C interface The elegance of Python T214 - Other Facilities in Tcl Coverage map in Tcl - how many times has each proc been called? What does Tcl do if you try to run a command that is not defined? Catching failed commands and not crashing the program in Tcl Exception handling in Tcl Expanding a list of parameters in Tcl - {*} and eval Trapping errors in Tcl - the safety net that catch provides Exceptions - Tcl style Tcl - catching an error before your program crashes Handling Binary data in Tcl (with a note on C) Stable sorting - Tcl, Perl and others AgtInvoke - a command to drive Agilent Tcl software extensions Converting between Hex and Decimal in Tcl Getting rid of variables after you have finished with them Shortened interactive commands Error handling in Tcl through catch pu daily and p hourly This article P216 - Handling Dates and Time Perl - turning seconds into days, hours, minutes and seconds Time conversions in Perl This article H999 - Additional PHP Material Image indexer / thumbnail display scripts in PHP Catchable fatal error in PHP ... How to catch, and alternative solutions such as JSON Arrays of arrays - or 2D arrays. How to program tables. Exception handling in PHP If nothing, make it nothing. Extra PHP Examples PHP Techniques - a workshop Flipping images on your web page Script to present commonly used images - PHP Copyright and theft of images, bandwidth and members. More PHP sample and demonstration programs Ordnance Survey Grid Reference to Latitude / Longitude Converting from postal address to latitude / longitude Controlling and labelling Google maps via PHP PHP Standalone - keyboard to screen Drawing hands on a clock face - PHP Drawing dynamic graphs in PHP Sorting people by name in PHP Parallel processing in PHP Dates, times, clickable diarys in PHP Display an image from a MySQL database in a web page via PHP Syntax checking in PHP Reporting on the 10 largest files or 10 top scores PHP - a team member leaves Check your user is human. Have him retype a word in a graphic Hot answers in PHP Presentation, Business and Persistence layers in Perl and PHP PHP Image viewing application PHP - setting sort order with an associative array Merging pictures using PHP and GD Running a Perl script within a PHP page Double Dollars in PHP Stand alone PHP programs Time calculation in PHP the array returned by preg_match_all More maps Ordnance Survey - using a 'Get a map' This article PHP and natural sorting