1. Command: Date
2, the command function: Date can be used to display or set the date and time of the system.
3. Command parameters
-d< string: Displays the date and time that the string refers to. Double quotation marks must be added before and after strings;
-s< string;: Sets the date and time according to the string. Double quotation marks must be added before and after strings;
-U: Display GMT;
--help: Online Help;
--version: Displays version information.
4. List of date format strings
%H hours (expressed in 00-23).
%I Hours (expressed in 01-12).
%K hours (expressed in 0-23).
%l hours (expressed in 0-12).
%M minutes (expressed in 00-59).
%P am or PM.
%r time (including hours, minutes and seconds, hour is expressed as 12 hours am/pm).
Total number of seconds in%s. The starting time is 1970-01-01 00:00:00 UTC.
%s seconds (as represented by local idioms).
%T time (minutes and seconds, hours are expressed in 24-hour system).
%x time (expressed in local idiomatic notation).
%Z downtown.
%a abbreviation of the week.
The full name of the%A week.
Abbreviation for%b month English name.
The full English name of the%B month.
%c date and time. Entering only the date instruction will also show the same result.
%d date (expressed as 01-31).
%d Date (including month date).
%F shows Yy-mm-dd.
%j the first day of the year.
%m month (expressed as 01-12).
%u the number of weeks in the year.
%w Day of the week one (0 for Sunday)
%W the first few weeks of the year (00. 53, Monday for first day)
%x is equivalent to%HH%MM%SS.
%y year (expressed in 00-99).
%Y year (expressed in four digits).
%n inserts a new line when it is displayed.
%t when displayed, Insert tab.
MM Month (required)
DD Date (required)
HH Hour (necessary)
MM min (required)
SS sec (Selective)
5. Example
formatted output time: Date + "%y-%m-%d"
Show Current date time: Date
displays the time two days ago and outputs it in%y-%m-%d%h:%m:%s format: date-d "+2 days Ago" "+%y-%m-%d%h:%m:%s"
Set Time:
Date-s "01:01:01 2017-12-12"//This can set the whole time
Date-s "01:01:01 20171212"//This can set the whole time
Date-s "2017-12-12 01:01:01"//This will set the whole time
Date-s "20171212 01:01:01"//This will set the whole time
6. Clock correlation (Hwclock/clock)
(1) View hardware time: Hwclock--show clock--show
(2) Set hardware time
Hwclock--set--date= "12/07/17 10:30:00" (Month/day/year: minutes: seconds)
Clock--set--date= "12/07/0615 10:30:00" (Month/day/year: minutes: seconds)
(3) Synchronization of hardware time and system time
Hwclock--hctosys (HC stands for hardware time, SYS stands for system time) or clock--hctosys
system clock and Hardware clock synchronization: Hwclock--SYSTOHC or Clock--SYSTOHC
7. Time and Time stamp
Date: Year-month-day such as: ' 2017-12-08 ' range from 0001-1-1 to 9999-12-31
Time: Hours: minutes: seconds: ' 23:59:59 '
Timestamp: Year-month-day hours: minutes: seconds (. Subtle number) such as: ' 2017-12-08 23:59:59.59 '
8.
UTC (Universal time COORDINATED,UTC) world coordination Times
CST China Time utc+8:00 (Beijing time)
GMT (Greenwich Mean Time) GMT
Date usage in Linux