1. The basic syntax
date [OPTION]... [+FORMAT]
2 . Option Description
Table 1-20
Options |
Features |
-d < time string > |
Displays the specified time "time string" representation, rather than the current time |
-s < datetime > |
Set the system date and time |
3. Parameter Description
Table 1-21
parameter |
Features |
<+ Date Time Format > |
Date and time format to use when displaying |
date displays the current time
1. The basic syntax
( . 1 ) DATE (Function Description: display the current time)
( 2 ) DATE% the Y + (Function Description : display the current year)
( . 3 ) DATE% + m (Function Description : The current month)
( . 4 ) DATE +% D (Function Description : currently displayed day)
( . 5 ) DATE "+% Y-M-% D%% H:% M:% S" (Function Description: year, month, day, hour display)
2. Case practical operation
( 1 ) shows the current time information
[root@hadoop101 ~]# date
2017 Nian 06 Yue 19 Monday 20:53:30 CST
( 2 ) displays the current date time
[root@hadoop101 ~]# date +%Y%m%d
20170619
( 3 ) displays the current date time minutes and seconds
[root@hadoop101 ~]# date "+%Y-%m-%d %H:%M:%S"
2017-06-19 20:54:58
date display non-current time
1. The basic syntax
( . 1 ) DATE -d '. 1 Days ago Member' (Function Description: Shows the previous day time )
( 2 ) DATE -d '-1 Days ago Member' (Function Description: Tomorrow Display Time )
2. Case practical operation
( 1 day before) display
[root@hadoop101 ~]# date -d '1 days ago'
2017 Nian 06 Yue 18 Sunday 21:07:22 CST
( 2 ) show time tomorrow
[root@hadoop101 ~]#date -d '-1 days ago'
2017 Nian 06 Yue 20 Sunday 21:07:22 CST
date sets the system time
1. The basic syntax
date -s string time
2. Case practical operation
( 1 ) Set the current system time
[root@hadoop101 ~]# date -s "2017-06-19 20:52:18"
cal View Calendar
1. The basic syntax
cal [ options ] (Functional Description: without option to display the calendar month)
2. Option Description
Table 1-22
Options |
Features |
A specific year |
This year's calendar is displayed |
3. Case practical operation
( 1 ) view the current month's calendar
[root@hadoop101 ~]# cal
( 2 ) View 2017 year calendar
[root@hadoop101 ~]# cal 2017