Bash convert epoch to date, showing wrong time Bash convert epoch to date, showing wrong time bash bash

Bash convert epoch to date, showing wrong time


This particular timestamp is in milliseconds since the epoch, not the standard seconds since the epoch. Divide by 1000:

$ date -d @1361234760.790Mon Feb 18 17:46:00 MST 2013


You can use bash arithmetic expansion to perform the division:

date -d @$((value/1000))

Note that "value" is a bash variable with the $ being optional; i.e., $value or value can be used.


For Mac OS X, it's date -r <timestamp_in_seconds_with_no_fractions>

$ date -r 1553024528Tue Mar 19 12:42:08 PDT 2019

or

$ date -r `expr 1553024527882 / 1000`Tue Mar 19 12:42:07 PDT 2019

or

$ date -r $((1553024527882/1000))Tue Mar 19 12:42:07 PDT 2019