Date Command In Linux

Piyush Panchariya
2 min readSep 22, 2021

What is date command ?

date command is used to display the system date and time. date command is also used to set date and time of the system. By default the date command displays the date in the time zone on which unix/linux operating system is configured.You must be the super-user (root) to change the date and time.This command also allows users to print the time in different formats and calculate future and past dates. date was written by David MacKenzie.


The syntax for the date command is:

date [option]... [+format]

How we can use date:


The output displays the day of the week, day of the month, month, year, current time, and time zone. By default, the date command is set to the time zone of the operating system.

date --date=("oct 5 2 years ago")

Use the --date option to display past dates in Linux. The date command accepts values such as "tomorrow", "Friday", "last Friday", "next Friday", "next week", and similar.

date --file="ro.txt"

It will show the date when file was made if file is empty. Here we use the cat command to add dates to a file and then print them with the date command.

*Most commonly used options:

  • %D – Display date as mm/dd/yy
  • %Y – Year (e.g., 2020)
  • %m – Month (01-12)
  • %B – Long month name (e.g., November)
  • %b – Short month name (e.g., Nov)
  • %d – Day of month (e.g., 01)
  • %j – Day of year (001-366)
  • %u – Day of week (1-7)
  • %A – Full weekday name (e.g., Friday)
  • %a – Short weekday name (e.g., Fri)
  • %H – Hour (00-23)
  • %I – Hour (01-12)
  • %M – Minute (00-59)
  • %S – Second (00-60)