strftime

by Tim Petricola on GitHub

FormatMeaningOutput
%aAbbreviated weekday nameFri
%AFull weekday nameFriday
%bAbbreviated month nameOct
%BFull month nameOctober
%CCentury number (year/100) as a 2-digit integer20
%dDay of the month, padded to 2 digits (01-31)01
%DEquivalent to %m/%d/%y in en-US10/01/21
%eDay of the month, padded with a leading space for single digit values (1-31) 1
%FEquivalent to %Y-%m-%d (the ISO 8601 date format)2021-10-01
%hEquivalent to %b (abbreviated month name)Oct
%HThe hour (24-hour clock), padded to 2 digits (00-23)09
%IThe hour (12-hour clock), padded to 2 digits (01-12)09
%jDay of the year, padded to 3 digits (001-366)274
%kThe hour (24-hour clock), padded with a leading space for single digit values (0-23) 9
%lThe hour (12-hour clock), padded with a leading space for single digit values (1-12) 9
%mThe month, padded to 2 digits (01-12)10
%nNewline character
%MThe minute, padded to 2 digits (00-59)19
%p"AM" or "PM"AM
%P"am" or "PM"am
%rEquivalent to %I:%M:%S %p (time in a.m. or p.m. notation)09:19:47 AM
%REquivalent to %H:%M (time in 24-hour notation)09:19
%sN umber of seconds since the Epoch (1970-01-01 00:00:00 +0000), UTC1633079987
%SThe second, padded to 2 digits (00-60)47
%tTab character
%TEquivalent to %H:%M:%S (time in 24-hour notation)09:19:47
%uWeekday, Monday being 1 (1-7)5
%UWeek number of the year, Sunday as the first day of the week, padded to 2 digits (00-53)39
%wWeekday, Sunday being 0 (0-6)5
%WWeek number of the year, Monday as the first day of the week, padded to 2 digits (00-53)39
%yThe year without the century (00-99)21
%YThe year with the century2021
%zThe +hhmm or -hhmm numeric timezone (that is, the hour and minute offset from UTC)+0000
%ZThe time zone name, replaced with an empty string if it is not foundCoordinated Universal Time
%%A % sign%
FlagMeaning
_(underscore) Pad a numeric result string with spaces (.e.g %_d)
-(dash) Omit leading zeroes or spaces (.e.g %-d)
0Force the use of zeroes as padding characters (.e.g %0e)