Nerd Notes

/dev/brain: no space left on device

UNIX time to human readable

with one comment

The current issue of the Gentoo Weekly Newsletter has a good clue on how to easily convert a date from the standard UNIX time format (which basically is a number which represents the number of seconds elapsed since January 1, 1970 at midnight, UTC) to a human readable form. The best solution is using date -d on Linux systems such as in:

$ date -d @1161911504
Fri Oct 27 03:11:44 CEST 2006

However, on BSD derived systems, such as Mac OS X (and maybe Solaris), date -d won’t work so you have to used instead:

$ date -r 1161911504
Fri Oct 27 03:11:44 CEST 2006

Advertisements

Written by Mirko Caserta

November 1, 2006 at 8:10 pm

Posted in CLI, Console, Linux, UNIX

One Response

Subscribe to comments with RSS.

  1. Unfortunately on older coreutils (date) versions such as 5.2.1 you can’t use @ syntax. Proper trick is to specify both timezone and Epoch:

    $date -d ‘@1161911504′
    date: invalid date `@1161911504’

    $ date -d ‘1970-01-01 UTC 1161911504 seconds’
    Fri Oct 27 03:11:44 CEST 2006

    kreator

    November 4, 2006 at 12:32 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: