Getting the current time in epoch-seconds

I already wrote about epoch-seconds, but there is a quicker way to get them, this time without resorting to Perl.

$ date "+%s"

Will return the current epoch-seconds, at the time of this writing 1191687083. This should work with most incarnations of the date-command. For the restless (a.k.a. the ones not willing to read the post linked to above), converting from epoch-seconds to human-readable time works like this:

$ date -r 1191687083

Or whatever second-count you want to convert, of course. One last thing to try:

$ date -r 0000000000

Returns the time your system deems to be the beginning of its time, usually January 1st 1970.

I have no idea, if some of this works on Windows™, it should though, if you’d install cygwin on it.

Technorati Tags: , , ,

One Comment

  1. dg
    Posted November 30, 2012 at 12:58 am | Permalink

    This was super helpful. Thanks!

Post a Comment

Your email is never published nor shared. Required fields are marked *, comments are moderated.