English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The Linux date command can be used to display or set the system's date and time. In terms of display, users can set the desired format, which is specified by a plus sign followed by several markers. The list of available markers is as follows:
Regarding the time:
Regarding the date:
If it is not preceded by a plus sign, it means to set the time, and the time format is MMDDhhmm[[CC]YY][.ss], where MM is the month, DD is the day, hh is the hour, mm is the minute, CC is the first two digits of the year, YY is the last two digits of the year, and ss is the number of seconds.
Access permission: All users.
When you do not want to display the meaningless 0 (such as 1999/03/07), you can insert - symbol, such as date '+%-H:%-M:%-S' will remove the meaningless 0 from the hours, minutes, and seconds, such as the original 08%T'9%T'4 will become 8:9:4. Only those who have the authority (such as root) can set the system time.
After you change the system time as root, remember to change the clock -Write the system time to CMOS, so that the system time will remain the latest correct value when the system is restarted next time.
date [-语法-date [-u] [--d datestr] [--s datestr] [--utc] [--universal] [--date=datestr] [--set=datestr] [+help] [
version] [FORMAT] [MMDDhhmm[[CC]YY][.ss]]
version : Display Version Number
Online Examples Display Current Time 5Display Numeric Date, Year Represented by Two Digits 12 14%T'8:12 # date 2010 Seconds+Wednesday 2010%x'5Display Numeric Date, Year Represented by Two Digits12CST 14Display9%c'2Hour 0 Seconds+Day Wednesday //Minute 0 05/12/10 Seconds+%D' //Display Complete Time 2010%x'5Display Numeric Date, Year Represented by Two Digits12Year 0 Seconds+Month //Day 14%T'9:31 Seconds+Display Date, Year Represented by Four Digits //:024%X' 14Display9Hour Format39Hour 0
Minutes
Seconds+:%M %P1Output in Your Own Format -# date ' :%M %P1:16 hey' -usr_time: $
Afternoon
date '+hey
Display Time Followed by a New Line, Then Display Current Date
date '+Display Month and Date
Display Date and Set Time (12:34:56)
date --date '12:34:56