Linux Date Command: Usage & Examples
In Linux, the date command is used to display or set the system’s date and time. Here are some common uses of the date command:
- Display the current date and time:
date
- Display the complete information of the current date and time (including the day of the week, time zone, etc.):
date "+%A, %B %d, %Y %T %Z"
- Display the current UNIX timestamp for the date.
date +%s
- Set system date and time:
sudo date -s "YYYY-MM-DD HH:MM:SS"
- Format the time into a specific format (e.g., displaying the current year of the date).
date "+%Y"
Here are some common uses of the date command, which you can adjust and combine according to your needs.