date用法1:
格式:date[OPTION]...[+FORMAT]
FORMATcontrolstheoutput.Interpretedsequencesare:
%%aliteral%
%alocale'sabbreviatedweekdayname(e.g.,Sun)
%Alocale'sfullweekdayname(e.g.,Sunday)
%blocale'sabbreviatedmonthname(e.g.,Jan)
%Blocale'sfullmonthname(e.g.,January)
%clocale'sdateandtime(e.g.,ThuMar323:05:252005)
%Ccentury;like%Y,exceptomitlasttwodigits(e.g.,20)
%ddayofmonth(e.g.,01)
%Ddate;sameas%m/%d/%y
%edayofmonth,spacepadded;sameas%_d
%Ffulldate;sameas%Y-%m-%d
%glasttwodigitsofyearofISOweeknumber(see%G)
%GyearofISOweeknumber(see%V);normallyusefulonlywith%V
%hsameas%b
%Hhour(00..23)
%Ihour(01..12)
%jdayofyear(001..366)
%khour,spacepadded(0..23);sameas%_H
%lhour,spacepadded(1..12);sameas%_I
%mmonth(01..12)
%Mminute(00..59)
%nanewline
%Nnanoseconds(000000000..999999999)
%plocale'sequivalentofeitherAMorPM;blankifnotknown
%Plike%p,butlowercase
%rlocale's12-hourclocktime(e.g.,11:11:04PM)
%R24-hourhourandminute;sameas%H:%M
%ssecondssince1970-01-0100:00:00UTC
%Ssecond(00..60)
%tatab
%Ttime;sameas%H:%M:%S
%udayofweek(1..7);1isMonday
%Uweeknumberofyear,withSundayasfirstdayofweek(00..53)
%VISOweeknumber,withMondayasfirstdayofweek(01..53)
%wdayofweek(0..6);0isSunday
%Wweeknumberofyear,withMondayasfirstdayofweek(00..53)
%xlocale'sdaterepresentation(e.g.,12/31/99)
%Xlocale'stimerepresentation(e.g.,23:13:48)
%ylasttwodigitsofyear(00..99)
%Yyear
%z+hhmmnumerictimezone(e.g.,-0400)
%:z+hh:mmnumerictimezone(e.g.,-04:00)
%::z+hh:mm:ssnumerictimezone(e.g.,-04:00:00)
%:::znumerictimezonewith:tonecessaryprecision(e.g.,-04,+05:30)
%Zalphabetictimezoneabbreviation(e.g.,EDT)
Bydefault,datepadsnumericfieldswithzeroes.Thefollowingoptionalflagsmayfollow`%':
-(hyphen)donotpadthefield
_(underscore)padwithspaces
0(zero)padwithzeros
^useuppercaseifpossible
#useoppositecaseifpossible
例如:
1.年月日
复制代码