I. Introduction to the DATE command
Function: Used to display time, this command is used much in the shell script
Format: Date + parameter + format
Parameter:-D to display the specified time
Date Show current time April 13, 2016 Wed 14:33:55 CST
date-s "2016-10-12 07:09:35" Manual modification Time Wednesday, October 12, 2016 07:09:35 CST
Automatic proofreading Time:
Yum install–y NTP ntpdate time.windows.com ntpdate ntp.fudan.edu.cn (optional) proofread Fudan's time server
Second, date format
%F: Month Day (full date)
%T: Hours and seconds (time)
%Y: Year (show four-bit) (years)
%y: Year (show two-bit) (years)
%m: Month (mouth)
%d: Day (date)
%H: When (hour)
%M: Min (minute)
%s: Seconds (second)
%s: Seconds (timestamp, which indicates how many seconds have passed from 1970.1.1 to now)
%w: Zhou (week)
%W: Week (week of the year, 52 weeks a year)
[Email protected] ~]#Date +%fShow date 2016-10-12[[email protected] ~]#Date +%tDisplay time division seconds 07:19:56[[email Protected] ~]#Date +%yDisplay year (four digits) 2016[[email protected] ~]#Date +%mShow month 10[[email protected] ~]#Date + "%y-%m-%d%h:%m:%s"Displays the custom time 2016-10-12 07:25:36[[email protected] ~]#DateShow current time October 12, 2016 Wed 07:29:48 Cst[[email protected] ~]#date-d "-2 days" +%fShowing two days ago 2016-10-10[[email protected] ~]#date-d "-2 month" +%fShow time two months ago 2016-08-12[[email protected] ~]#date-d "-2 hour" +%tShowing two hours ago 05:30:39[[email protected] ~]#date-d "-2 min" +%tShowing two minutes ago 07:28:49[[email protected] ~]#date-d "-2 sec" +%tShowing two seconds ago 07:30:52
Shell command: Date