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:

  1. Display the current date and time:
date
  1. 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"
  1. Display the current UNIX timestamp for the date.
date +%s
  1. Set system date and time:
sudo date -s "YYYY-MM-DD HH:MM:SS"
  1. 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.

bannerAds