January 06, 2010, 12:27 PM — The new year rolled in at 1262304000, Unix time that is. It's a little hard to imagine that Unix is now more than 1.2 billion seconds old. Seems only yesterday that I was trying my first pipes and grep commands while thinking "Wow, this is groovy". OK, maybe not quite "groovy", but close!
Over the decades since the inception of Unix, its fans have gone through numerous "best one-liner" and "how to squeeze X nanoseconds out of your scripts" exercises. We've also gone through geeky Unix joke phases with the likes of:
% cat 'the can of tuna' cat: cannot open the can of tuna
In that more than 1.2 billion seconds, Unix has evolved considerably, but time is still calculated in the same way. Unix time, also known as "epoch time" is, of course, the number of seconds that have passed since Jan 1, 1970.
It's hard to think in Unix time. I'd have a hard time just remembering how many minutes are in a day (525,600) if it weren't for the song from the musical "Rent" that I like to sing. Thinking in seconds is just that much harder.
Unix was one year old in 31536000, two years old in 63072000 and three years old in 94694400 (94608000 + 86400 for leap year). I've been using Unix for more than 825 million seconds. That's a lot of seconds!
To convert Unix time to people time (or vice versa), you can use online web converters like these:
You can use the Perl time() command to convert current time to Unix time:
#!/bin/perl print "Current Unix time is: " . time() . "\n";
To convert Unix time into people time, you can just plug a formula into Excel. Yes, Excel. After all, it's just a calculation, right? Here's all you have to do.
The "A3 / 86400" part of this formula will turn your Unix date (the number of seconds since the start of the Unix epoch) into the number of days since the epoch began. 86400 is the number of seconds in a day (24 * 60 * 60). Adding 25569 fills in the number of days from year 0 to the beginning of 1970. In other words, we hand Excel the number of days since the beginning of year 0 and it displays this number as a date.