Convert epoch seconds to datetime
Some of the logs I debug often contain the timestamp in the form of epoch seconds, so I frequently had to convert them into readable datetime format. Noting this down for a quick reference.
# % date -r <seconds> ~ % date -r 1220355645 Tue Sep 2 07:40:45 EDT 2008
# date -d @<seconds> $ date -d @1120355645 Sat Jul 2 21:54:05 EDT 2005
coreutils date conversion specifiers
Display current time in epoch seconds
(common to both macOS and coreutils)
~$ date +%s 1620355706