Guidelines

This site is for tech Q&A. Please keep your posts focused on the subject at hand.

Ask one question at a time. Don't conflate multiple problems into a single question.

Make sure to include all relevant information in your posts. Try to avoid linking to external sites.

Links to documentation are fine, but in addition you should also quote the relevant parts in your posts.

0 votes
264 views
264 views

The date command can display the time in Unix epoch format (seconds since 1970-01-01 0:00:00) like this:

date +%s

But how do I convert a timestamp in epoch format back to a human-readable date/time?

in Scripting
by (115)
2 19 33
edit history

Please log in or register to answer this question.

1 Answer

0 votes
 

The date command can do that as well. Prefix the epoch timestamp with @ and pass that to the command as the date string (via the parameter --date/-d):

ts="$(date +%s)"
date --date @"$ts"
by (115)
2 19 33
edit history
...