Summary of knowledge points of Linux date command

  • 2021-07-22 12:16:43
  • OfStack

Usage: date [option]... [+ format] or: date [-u--utc--universal] [MMDDhhmm [[CC] YY] [. ss]]

Displays the current time in the given format, or sets the system date.

-d,--date = The string displays the time described by the specified string instead of the current time
-f,--file = Date file similar--date, read the time description in line from the date file
-r,--reference = File Display File Specified File Last Modified Time
-R,--rfc-2822 Output date and time in RFC 2822 format
For example: Monday, August 7, 2006, 12:34:56-0600
--rfc-3339=TIMESPEC outputs date and time in RFC 3339 format.
TIMESPEC = ` date ', ` seconds', or ` ns '
Indicates the display accuracy of the date and time.
Date and time cells are separated by a single space:
2006-08-07 12:34:56-06:00
-s, --set = string setting specifies a string to separate time
-u,--utc,--universal output or set coordinated universal time
--help displays this help message and exits
--version displays version information and exits

The given format FORMAT controls the output, and the interpretation sequence is as follows:

% of%% 1 text
% a the abbreviation of the current locale week name (for example, day, for Sunday)
% A the full name of the current locale week (e.g. Sunday)
% b the abbreviation of the current locale month name (e.g. 1 for January)
% B the full name of the month of the current locale (e.g. January)
% c the date and time of the current locale (e.g. week March 3, 2005, 423:05:25)
% C century; For example,% Y usually omits the last two digits of the current year (for example, 20)
% d Monthly Dates (for example: 01)
% D monthly date; Equal to% m/% d/% y
% e Date by month, add space, equal to% _d
% F full date format, equivalent to% Y-% m-% d
The last two bits of the year in the% g ISO-8601 format (see% G)
% G ISO-8601 Format Year (see% V), 1 generally used only in conjunction with% V
% h equals% b
% H hours (00-23)
% I hours (00-12)
% j Dates by Year (001-366)
% k (0-23)
% l (1-12)
% m month (01-12)
% M score (00-59)
% n Wrap
% N nanoseconds (000000000-99999999)
% p "morning" or "afternoon" under current locale, output is empty when unknown
% P is similar to% p but outputs lowercase letters
% r 12-hour clock time under current locale (e.g. 11:11:04 PM)
% R hours and minutes for a 24-hour period, equivalent to% H:% M
% s the number of seconds elapsed since UTC time 1970-01-01 00: 00:00
% S seconds (00-60)
% t Output tab Tab
% T time, equal to% H:% M:% S
% u week, 1 for week 1
% U week of a year with Sunday as the first day of the week (00-53)
Week of the year under the% V ISO-8601 format specification, with week 1 as the first day of the week (01-53)
% w Day of the week (0-6), 0 for Week 1
% W week of a year with week 1 as the first day of the week (00-53)
% x Date description under current locale (e.g. 12/31/99)
% X Time description under current locale (e.g. 23:13:48)
The last two digits of% y year (00-99)
% Y year
% z + hhmm Digital Time Zone (for example,-0400)
%: z + hh: mm Digital Time Zone (for example,-04:00)
%:: z + hh: mm: ss Digital Time Zone (for example,-04:00:00)
%::: z digital time zone with necessary precision (for example,-04, +05:30)
% Z alphabetical time zone abbreviations (for example, EDT)

By default, the numeric area of a date is filled with 0.

The following optional tags can be followed by "%":

-(hyphen) does not fill the field
_ (underscore) Fill with spaces
0 (number 0) is filled with 0
^ Use capital letters if possible
# Use the opposite case if possible

Allows an optional field width designation after any mark, which is a decimal number.

As an optional decorative declaration, it can be E, using local environment associated if possible

Representation; Or O, using numeric symbols associated with the local environment where possible.

Above is this site this site for all the relevant content, thank you for your study and support.


Related articles: