Skip to content

How to convert timestamp from Hexadecimal format to EPOCH timestamp?

I am looking for a Linux command to convert hexadecimal time format to Linux timestamp. I have tried this command:

date "+%Y-%m-%d %H:%M:%S ( %s )" --date="@$(printf "%dn" 0xd6979880)"
output >> 2084-02-01 11:00:00 ( 3600259200 )

But it seems to be wrong, the epoch output of 0xd6979880 should be 1391270400. Please correct me if I am wrong.



From your description (expecting 1391270400 instead of 3600259200), at appears that your hex dates are seconds since 1900-01-01 rather than POSIX timestamps (seconds since 1970-01-01). Fortunately, it’s very easy to correct this offset, just by subtracting 70 years:

$ date '+%F %T ( %s )' --date="$(date -d @$(printf "%d" 0xd6979880)) - 70 years"
2014-02-01 16:00:00 ( 1391270400 )
User contributions licensed under: CC BY-SA
2 People found this is helpful