Convert seconds to human-readable format

This example, for example, produces the output, "Fri Feb 13 15:26:30 EST 2009"

By: kFiddle
2009-04-11 22:26:41

What Others Think

Cool! Except it returns Fri Feb 13 18:31:30 EST 2009. I wonder where the 3hrs 5min different came from?
birnam · 614 weeks and 4 days ago
On OS X and BSD variants the equivalent seems to be date -r 1234567890
qubyte · 614 weeks and 3 days ago
[[ `grep -i ego jnash | wc | awk '{print $1}'` -gte 1 ]] && echo "Yep! ;-)" || echo "My bad"
mark_stafford · 614 weeks and 1 day ago
Nice trick. I usually use 'perl -e "print localtime 1234..."' but this is clearly better.
amosshapira · 614 weeks ago
Not solaris compatible...
MoHaG · 585 weeks ago
Oh god, I wish I knew of this last year. I learned the BSD (in my case OSX) version of date -r 1234567890 and loved it. I talked to a friend of mine and he suggested something along the lines of; date -d "1234567890 seconds ago UTC" Needless to say I have a new better way of doing it.
VxJasonxV · 541 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: