Date Command in Linux

Dolly Chauhan
3 min readSep 22, 2021

https://www.linkedin.com/in/dolly-chauhan-28225b208

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. It is most commonly used to print the date and time in different formats and calculate future and past dates. The author of date command is David MacKenzie.

Syntax :

date [OPTION] ... [+FORMAT]
ex- date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

Options in date command (with example)

  1. -u Option : displays the time in UTC(Coordinated Universal Time) time zone.

2. –date or -d Option: Displays the given date string in the format of date.

3. Using –date option for displaying past and future dates

4.-s or –set Option: To set the system date and time -s or –set option is used.

5.List of Format specifiers used with date command:

a) %a and %A : displays the abbreviated name and full name for weekdays.

b) %b and %B : displays abbreviated and full month name.

c) %e : displays the day of the month.

d) %H : displays the hour (00….23)

e) %j : displays th day of the year (0….366)

f) %M and %N : displays the minute(0..59) and nanoseconds(000000000…999999999)

g) %U : displays the current week number (0…53).

h) %Y : displays four digit year

i) %Z : displays the alphabetic time zone( e.g. EDT)

j) %D : displays the date as mm/dd/yy.

Thank You for reading….

--

--