Date Command in Linux
2 min readSep 29, 2021
Date commands gives us date and time in terminal. It provide us multiple options, let us explore those options.
Let’s Start
Run below command in terminal to get systems current date and time.
date
To see Manual of Date Command
man date
To see help of Date Command
date --help
Lets explore some of options of Date command
- +%D → Display date as mm/dd/yy.
- +%d → Display the day of the month (01 to 31).
- +%A → Displays full weekdays (Sunday to Saturday).
- +%a → Displays the abbreviated name for weekdays (Sun to Sat).
- +%h → Displays abbreviated month name (Jan to Dec).
- +%b → Displays abbreviated month name (Jan to Dec).
- +%B → Displays full month name(January to December).
- +%m → Displays the month of the year (01 to 12).
- +%M → Display the minute.
- +%y → Displays last two digits of the year(00 to 99).
- +%Y → Display four-digit year.
- +%T → Display the time in 24 hour format as HH:MM:SS.
- +%H → Display the hour.
- +%S → Display the seconds.
- +%c → Displays local’s date and time.
- +%C →Displays century but it omits last two digits.
- +%e → Displays day of month, space padded.
- +%F → Displays full date.
- +%g → Displays last two digits of year of ISO week number.
- +%G → Displays year of ISO week number.
- +%I → Displays hour (01–12).
- +%k → Displays hour (0..23).
- +%N → Displays nanoseconds.
- +%P → Displays locale’s equivalent of either AM or PM.
- +%q → Displays quarter of year(1..4).
- +%u → Displays day of week.
- +%U → Displays week number of year.
Likewise you can check other options too.
Extra Options
Date with “--date” option
date --date="tomorrow"
date --date="next sunday"
date --date="10 months ago"
These are some options of date but there are more we can customize them according to our use case.
That’s All, Keep Learning.
! THANK YOU For Reading !