Bootstrap FreeKB - Linux Fundamentals - Understanding epoch time
Linux Fundamentals - Understanding epoch time

Updated:   |  Linux Fundamentals articles

On a Linux system, epoch is the number of seconds that have elapsed since January 1st, 1970.

The date command with the %s option can be used to display the current epoch time. In this example, 1643368599 seconds have elapsed since January 1st, 1970.

~]$ date +%s
1643368599

 

And here is how you could convert an epoch time to human readable date time.

~]$ date -d @1655380828
Thu Jun 16 07:00:28 CDT 2022

 

Or, you can also use echo or printf.

~]$ echo $(date +%s)
1643368599

 

And here is how you could convert an epoch time to human readable date time.

~]$ echo $(date -d @1655380828)
Thu Jun 16 07:00:28 CDT 2022

 

Often you'll want to return the result in UTC.

~]$ echo $(date -d @1655380828 --utc)
Thu Jun 16 12:00:28 UTC 2022

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter a64ac8 in the box below so that we can be sure you are a human.