date command

LINUX-Frequently used commands

date command View, set, and change the current date and time.
Syntax
date   [Option]  [Date and time]
The date command is used to display and set the system date and time for Linux.
The super user (root) can change the system date by specifying "-s" as an option to the date command and specifying the date and time as arguments.
You can also change the system date by specifying the format.
You can also change the way the date and time are displayed by specifying the format.
Frequently used options
-s [Date and time]    Set the date and time as the system date and time.
+[format]                Displays the date and time in the format specified by the format
Example: Display the date and time.
$ date
Nov 22, 2019, 15:06:24 JST 
Example: Set the date and time
$ su - ← Become the super user root
Password:  ←Enter in the root password
# date 120511002021 ← Set the system date and time to "December 05, 2021 11:00
Sunday, December 05, 2021 11:00:00 JST
Example: Display the date and time in a specific format.
$ date +%y%m%d
211205 ← "December 05, 2021"
Example: Display time in 24-hour format
$ date +%T
21:09:15
Example: Display time in 12-hour format
$ date +%r
09:09:15 PM
Copied title and URL