Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

How do I convert an epoch timestamp to a human readable format on the cli? I think there's a way to do it with date but the syntax eludes me (other ways welcome).

share|improve this question
whats the problem with the date syntax? you don't like the formatting options? I think a date -d @TIMESTAMP is really simple... – echox Oct 11 '10 at 13:57
@echox I was completely not seeing the @TIMESTAMP in the docs. – xenoterracide Oct 11 '10 at 13:59
ah, ok, that explains it :-) – echox Oct 11 '10 at 14:00

7 Answers 7

up vote 67 down vote accepted

On *BSD:

date -r 1234567890

On Linux (specifically, with GNU coreutils ≥5.3):

date -d @1234567890

With older versions of GNU date, you can calculate the relative difference to the UTC epoch:

date -d '1970-01-01 UTC + 1234567890 s'

If you need portability, you're out of luck. The only time you can format with a POSIX shell command (without doing the calculation yourself) line is the current time. In practice, Perl is often available:

perl -le 'print scalar localtime $ARGV[0]' 1234567890
share|improve this answer
+1 for the comment about the lack of portability (why doesn't the POSIX spec include a way to do this? grr) – Richard Hansen Feb 1 '12 at 22:50
What does the @ mean in date -d @1234567890? man date made no reference to that... – Chris Markle Jan 14 '13 at 21:10
@ChrisMarkle GNU man pages are often woefully incomplete. “The date string format is more complex than is easily documented here but is fully described in the info documentation.” To wit:… – Gilles Jan 14 '13 at 21:56

date -d @1190000000 Replace 1190000000 with your epoch

share|improve this answer
Assuming GNU date, that is. – Gilles Oct 11 '10 at 18:14
$ echo 1190000000 | perl -pe 's/(\d+)/localtime($1)/e' 
Sun Sep 16 20:33:20 2007

This can come in handy for those applications which use epoch time in the logfiles:

$ tail -f /var/log/nagios/nagios.log | perl -pe 's/(\d+)/localtime($1)/e'
[Thu May 13 10:15:46 2010] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;HOSTA;check_raid;0; OK (Unit 0 on Controller 0 is OK)
share|improve this answer

With bash-4.2 or above:

printf '%(%F %T)T\n' 1234567890

(where %F %T is the strftime()-type format)

That syntax is inspired from ksh93.

In ksh93 however, the argument is taken as a date expression where various and hardly documented formats are supported.

For a Unix epoch time, the syntax in ksh93 is:

printf '%(%F %T)T\n' '#1234567890'

ksh93 however seems to use its own algorithm for the timezone and can get it wrong. For instance, in Britain, it was summer time all year in 1970, but:

$ TZ=Europe/London bash -c 'printf "%(%c)T\n" 0'
Thu 01 Jan 1970 01:00:00 BST
$ TZ=Europe/London ksh93 -c 'printf "%(%c)T\n" "#0"'
Thu Jan  1 00:00:00 1970
share|improve this answer

The two I frequently use are:

$ perl -leprint\ scalar\ localtime\ 1234567890
Sat Feb 14 00:31:30 2009


$ tclsh
% clock format 1234567890
Sa Feb 14 00:31:30 CET 2009
share|improve this answer

With zsh you could use the strftime builtin:

strftime format epochtime

      Output the date denoted by epochtime in the format specified.


zmodload zsh/datetime
strftime '%A, %d %b %Y' 1234567890
Saturday, 14 Feb 2009
share|improve this answer

Custom format with GNU date:

date -d @1234567890 +'%Y-%m-%d %H:%M:%S'

Or with GNU awk:

awk 'BEGIN { print strftime("%Y-%m-%d %H:%M:%S", 1234567890); }'

Linked SO question:

share|improve this answer
Only works for GNU date and GNU awk. Neither awk nor nawk support strftime. – DarkHeart Jul 28 '14 at 3:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.