How to convert seconds since the epoch to a date in Linux?

How to convert seconds since the epoch (1970-01-01 UTC) to a date in Linux?

For example,

Convert the time stamp 1349361711.169942 to

Thu Oct  4 22:41:51 HKT 2012

You can use the date command on Linux to convert the time formats.

For converting the time stamp 1349361711.169942 to the normal data format:

$ date -d @1349361711.169942 
Thu Oct  4 22:41:51 HKT 2012

You can control the format of the output by add +FORMAT at the end of the command. For detailed introduction to the FORMAT string, check the manual of date.

Leave a Reply

Your email address will not be published. Required fields are marked *