Feb 2, 2013

// // Leave a Comment

Unix Timestamp and January 1, 1970


Unix timestamp
While coding in PHP and Open Source Technologies i always used to see this date -'January 1, 1970'. Always wondered what could be the reason this date has been set as default, and some research and reading this is what I understood.



'1st January 1970' usually called as "epoch date" is the date when the time started for Unix computers, and that time stamp is marked as '0'. Any time since that date is calculated based on the number of seconds elapsed. In simpler words... the time stamp of any date will be difference in seconds between that date and '1st January 1970'. PHP uses this mechanism, and its pretty easy to manipulate dates using this mechanism. The next day or previous day can be found by adding or subtracting (60X60X24=86400 seconds) to the present time stamp.

The time stamp is just a integer which started from number '0' on 'Midnight 1st January 1970' and goes on incrementing by '1' as each second pass. For conversion of UNIX timestamps to readable dates PHP and other open source languages provides built in functions.

Wiki says: http://en.wikipedia.org/wiki/Unix_time 

NOTE: this doesn't take account of leap seconds 
Share on:

0 comments:

Post a Comment