Showing posts with label perl. Show all posts
Showing posts with label perl. Show all posts

2009-01-16

February 13th - The end of the universe as we know it?

First off, February 13th is my wife's birthday. Yes, the day before Valentine's day. No, I can't just get her one big gift for both at the same time. That landed me in the dog-house in 1998. I won't try that again.

But further, on the Cowtown Computer Congress of KC mailing list, someone pointed out that there's an exciting event in epoch time happening that day. For exactly one second, the epoch clock will read 1,234,567,890 seconds past midnight, Jan 1, 1970.


Using my perl epoch time example:

$ perl -e 'print scalar localtime('1234567890'); print "\n";'
Fri Feb 13 17:31:30 2009

Of course, that's GMT-6 (US/Central)

So, the epoch (epic?) clock will tick 1234567890 on a Friday The Thirteenth. Apocalypse? Insanity? You be the judge.

2008-01-22

Perl: Convert epoch seconds to readable time

As a system administrator, It's not uncommon to run across time stamps represented in Epoch Seconds, that is basically the number of seconds that have passed since the start of Jan 1, 1970 UTC.  I most often run across these time stamps stored in database records, but you'll see it elsewhere, too.   An Epoch time stamp for any fairly recent date looks like a huge string of digits, such as "1201017672".  Obviously, time stamps closer to the beginning of the 1970 Epoch are significantly smaller.

To make some kind of sense out of that stamp, you can use perl's localtime() function right from the UNIX command-line.
$ perl -e 'print scalar localtime('1201017672'); print "\n";'
Tue Jan 22 10:01:12 2008