Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Detailed explanation of SHELL DATE command

Shulou Source: shulou.com Published: 2022-06-01 03:32:48 10月06日 Update

Usage: date [- u] [- d datestr] [- s datestr] [--utc] [--universal] [--date=datestr] [--set=datestr] [--help] [--version] [+ FORMAT] [MMDDhhmm [[CC] YY] [.ss]]

Note: date can be used to display or set the date and time of the system. In terms of display, users can set the format they want to display. The format is set to a plus sign followed by several tags. The list of available tags is as follows:

In terms of time:

%: print out

% n: next line

% t: tabbed

% H: hours (00.23)

% I: hours (01.. 12)

% k: hour (0.23)

% l: hour (1.. 12)

% M: minutes (00.59)

% p: show local AM or PM

% r: direct display time (12-hour format in hh:mm:ss [AP] M)

% s: seconds since 00:00:00 UTC on January 1, 1970% S: seconds (00.61)

% T: direct display time (24-hour system)

% X: equivalent to% H:%M:%S

% Z: show time zone

In terms of date:

% a: what day of the week (Sun..Sat)

% A: what day of the week (Sunday..Saturday)

% b: month (Jan..Dec)

% B: month (January..December)

% c: display date and time directly

% d: day (01.31)

% D: direct display date (mm/dd/yy)

% h: same as% b

% j: day of the year (001. 366)

% m: month (01.. 12)

% U: week ordinal of the year (00.53) (with Sunday as the first day of the week)

% w: day of the week (0.6)

% W: week ordinal of the year (00.53) (with Monday as the first day of the week)

% x: direct display date (mm/dd/yy)

% y: last two digits of the year (00.99)

% Y: full year (000.9999)

If you do not start with a plus sign, you want to set the time, and the format of the time is MMDDhhmm [[CC] YY] [.ss]

Where MM is the month

DD is the day

Hh is hour

Mm is minutes

CC is the first two digits of the year

YY is the last two digits of the year

Ss is number of seconds

Set up a plan:

-d datestr: displays the time set in datestr (non-system time)

-help: displays auxiliary messages

-s datestr: sets the system time to the time set in datestr

-u: displays the current Greenwich mean time

-version: displays the version number

Tags: Time hour date year month format number aspect system plus sign situation week tag line user beginning method time zone version if yes Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Microsoft MariaDB Apple Linux