In Linux, the time is divided into two types: 1; Use the date command to display the system time, 2 to display hardware time using clock or Hwclock
The system time and hardware time will appear out of sync.
Man Command =manual= command manual
Here's how to use Date:
1 Use the date command to view the current time directly:
[Email protected] ~]#
[[Email protected] ~]# Date
Thu Dec 8 20:36:21 CST 2016
2 Modifying a time with the date command
Date [OPTION] ... [+format]
Date [-u|--utc|--universal] [MMDDHHMM[[CC]YY][.SS]]
Month Day hour minute year. seconds
# date 1208204516.30
3: Format:
Percent a literal%
%a Locale ' s abbreviated weekday name (e.g., Sun) shows the day of the week in abbreviated ways
%A locale ' s full weekday name (e.g., Sunday) displays today's Day of the week with full name
%b Locale ' s abbreviated month name (e.g., Jan) Displays the current month shorthand
%B locale ' s full month name (e.g., January) displays the full name of the current month
%c locale ' s date and time (e.g., Thu Mar 3 23:05:25 2005) show current times
For example:
# date +%c
Thu Dec 09:08:50 PM CST
%c century; Like%Y, except omit the last of the digits (e.g., 20) Show century: as shown 20th century
%d day of month (e.g., 01) shows today the day of the month
%d date; Same as%m/%d/%y display time in month/day/year format
%e Day of month, space padded; Same as%_d show today for the day ordinal of the month
%F full date; Same as%y-%m-%d in month and day format 2016-12-8
%g last digits of the year of the ISO week number (see%G)
%G year of the ISO week number (see%V); Normally useful only with%V
%h Same as%b
%H Hour (00..23)
%I Hour (01..12)
%j Day of the Year (001..366)
%k Hour, Space padded (0..23); Same as%_h
%l Hour, Space padded (1..12); Same as%_i
%m Month (01..12)
%M minute (00..59)
%n a newline
%N nanoseconds (000000000..999999999)
%p locale ' s equivalent of either AM or PM; Blank if not known represents PM
%P like%P, but lower case
%r locale ' s 12-hour clock time (e.g., 11:11:04 PM) 12-hour display times
%R 24-hour hour and minute; Same as%h:%m 24-hour display hours: minutes
%s seconds since 1970-01-01 00:00:00 UTC from January 1, 1970 to today's number of seconds
%s second (00..60) sec
%t a tab
%T time; Same as%h:%m:%s display time in hours: minutes: seconds
%u day of week (1..7); 1 is Monday
%u week number of year, with Sunday as First day of week (00..53)
%V ISO Week number, with Monday as First day of week (01..53)
%w Day of Week (0..6); 0 is Sunday
%W Week number of year, with Monday as First day of week (00..53)
%x locale ' s date representation (e.g., 12/31/99) shows month/day/year
%x locale ' s time representation (e.g., 23:13:48) When displayed: minutes: Seconds
%y last two digits of the year (00..99) shows the final double digits of the years
%Y year
%z +hhmm numeric time zone (e.g.,-0400)
%:z +hh:mm numeric time zone (e.g., -04:00)
%::z +hh:mm:ss numeric time zone (e.g., -04:00:00)
%:::z numeric time zone with:to necessary precision (e.g.,-04, +05:30)
%Z Alphabetic time zone abbreviation (e.g., EDT)
#date +%d---Display dates in month/day/year format
12/08/16
# Date +%m---Display the current minute
#date +%m---Show month of the month
#date +%y---Display four-digit year (2016)
#date +%y----Show two digits after year (16)
#date + "This is%y"----shown as--this year is 2016
#date +%y-%m-%d by format year-month-day display
#date +%h:%m:%s
#hwclock-W means synchronizing the system time to the hardware
#hwclock-S means synchronizing hardware time to the system
Linux Date Usage