The 2,date command is used to display, set the system's time or date, in the following format: date[option][+ specify format].
The detailed format for date is as follows:
Date command Format
| Parameters |
Role |
| %t |
Skip the [tab] key |
| %H |
Hours (00-23) |
| %I |
Hours (01-12) |
| %M |
Minutes (00-59) |
| %s |
Seconds (00-59) |
| %x |
Equivalent to%h:%i:%s |
| %Z |
Show Time zone |
| %p |
Show local AM or PM |
| %A |
Day of the Week (Sunday-saturday) |
| %a |
Day of the Week (SUN-SAT) |
| %B |
Full month (January-december) |
| %b |
Abbreviated month (JAN_DEC) |
| %d |
Day (01-31) |
| %j |
Day of the Year (001-336) |
| %m |
Month (01-12) |
| %Y |
Full year |
|
|
|
|
|
|
Case
@1, viewing current system time
Date
@2, according to "year-month-day hours: minutes: Seconds" format display
Date " +%y-%m-%d%h:%m:%s "
@3, set the system time date is September 1, 2016 8:30: Update hardware clock plus hwclock-w
Date " 20160901 8:30:00 "
[Email protected] ~]# hwclock-w
@4, see the Day of the week
Date +%a
@5, judging today is the first day of the year
Date +%j
LINUX-8 Basic Command---Date