How can Linux display Unix timestamps?

In Linux, the date command can be used to display the Unix timestamp, which represents the number of seconds that have passed since January 1, 1970.

To display the current Unix timestamp, you can enter the following command in the command line:

date +%s

This will output a 10-digit number representing the current Unix timestamp.

To convert a specific date and time to a Unix timestamp, you can use the following command:

date -d "YYYY-MM-DD HH:MM:SS" +%s

Replace YYYY-MM-DD HH:MM:SS with a specific date and time, then run the command. This will output the corresponding Unix timestamp.

To convert a specific Unix timestamp to a date and time, you can use the following command:

date -d @<timestamp>

Replace with a specific Unix timestamp, then run the command. This will output the corresponding date and time.

Leave a Reply 0

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


广告
Closing in 10 seconds
bannerAds