Skip to Content

The date command

Posted in

All values in "seconds" is the number of seconds from Epoch, Jan 1, 1970.

  1. Current time in seconds.
    date +%s
    1220815239
  2. Convert 1220815239 seconds to a human readable date.
    date -d @1220815239
    Sun Sep 7 15:20:39 EDT 2008
  3. Convert 1220815239687 milliseconds to a human readable date.
    date -d @$[1220815239687/1000]
    Sun Sep 7 15:20:39 EDT 2008

Use these commands when you need to convert on the fly. Be mindful that some Unix timestamps may be presented in UTC (GMT). If working in GMT, append -u to date.

date -d @$[1220815239687/1000] -u
Sun Sep 7 19:20:39 UTC 2008