In shell, the display format of commonly used date is as follows:
Date + % f // 2007-03-06
Date + % Y % m % d // 20070306
Date + % t // 23:37:11
// Yesterday
Date + % Y % m % d-d "-1 day"
// Tomorrow
Date + % Y % m % d-d "+ 1 day"
// Last month
Date + % Y % m % d-d "-30 day"
Time modification:
Date-s 06:01:00 // hour: minute: Second
Date 1011200606 // month date hour minute year
Date = 'date + % Y % m % d'
Use wiki $ date after CP
% A abbreviation of the day of the week
% A full name of the day of the week
Abbreviation of % B month
% B full name
% C standard date time string
The last two digits of the Year % C
% D indicates the day of the month in decimal format.
% D month/day/year
% E indicates the day of the month in decimal format in the two-character field
% F-month-day
The last two digits of the Year % G. The year is based on the week.
% G year, based on the week Year
% H abbreviated month name
% H in 24-hour format
% I 12-hour
% J indicates the day of the year in decimal format.
Month in % m decimal format
% M decimal number of minutes
% N new line operator
% P equivalent display of local am or PM
% R 12 hours
% R display hour and minute: hh: mm
% S decimal seconds
% T horizontal Tab
% T display time in seconds: hh: mm: SS
% U the day of the week, Monday is the first day (value ranges from 0 to 6, Monday is 0)
% U indicates the week of the year. Sunday is regarded as the first day (the value ranges from 0 to 53)
% V indicates the week of the year, which is based on the year of the week.
% W decimal indicates the day of the week (the value ranges from 0 to 6, and Sunday is 0)
% W indicates the week of the year. Monday is the first day (from 0 to 53)
% X standard date string
% X standard time string
% Y does not contain the century's decimal year (the value ranges from 0 to 99)
% Y indicates the decimal Year of the century.
% Z, % Z Time Zone name. If the time zone name cannot be obtained, an empty character is returned.
Time Format method in Shell