Skip to main content
3 of 3
rm noise
tshepang
  • 67.7k
  • 94
  • 227
  • 297

How can I get a formatted date for a UNIX timestamp from the command line

I have a UNIX timestamp and I'd like to get a formatted date (like the output of date) corresponding to that timestamp.

My attempts so far:

$ date +%s 1282367908 $ date -d 1282367908 date: invalid date `1282367908' $ date -d +1282367908 date: invalid date `+1282367908' $ date +%s -d +1282367908 date: invalid date `+1282367908' 

I'd like to be able to get output like:

$ TZ=UTC somecommand 1282368345 Sat Aug 21 05:25:45 UTC 2010 
Umang
  • 1.2k
  • 1
  • 7
  • 10