Skip to main content
Version: 2.8.x(Latest)
warning

Note: The gtime.Time object uses the Format method to achieve custom formatted date and time conversion, which conflicts with the Format method of the standard library time.Time. In the gtime.Time object, the Layout method is used to implement the Format format of the standard library time.Time, for example: t.Layout('2006-01-02 15:04:05').

Below is the list of time format syntax supported by the gtime module:

FormatDescriptionExample Return Value
Day----
dDay of the month, 2 digits with leading zeros01 to 31
DDay of the week, textual representation, 3 lettersMon to Sun
NISO-8601 numeric representation of the day of the week1 (Monday) to 7 (Sunday)
jDay of the month without leading zeros1 to 31
l("L" lowercase) Full textual representation of the day of the weekSunday to Saturday
SEnglish suffix for the day of the month, 2 charactersst, nd, rd, or th. Can be used with j
wNumeric representation of the day of the week0 (Sunday) to 6 (Saturday)
zDay of the year0 to 365
Week----
WISO-8601 week number of the year, starting on Mondaye.g., 42 (42nd week of the year)
Month----
FFull textual representation of a monthJanuary to December
mNumeric representation of a month, with leading zeros01 to 12
MShort textual representation of a month, 3 lettersJan to Dec
nNumeric representation of a month, without leading zeros1 to 12
tNumber of days in the given month28 to 31
Year----
YFull numeric representation of a year, 4 digitse.g., 1999 or 2003
yTwo-digit representation of a yeare.g., 99 or 03
Time----
aLowercase Ante meridiem and Post meridiemam or pm
AUppercase Ante meridiem and Post meridiemAM or PM
g12-hour format of an hour, without leading zeros1 to 12
G24-hour format of an hour, without leading zeros0 to 23
h12-hour format of an hour, with leading zeros01 to 12
H24-hour format of an hour, with leading zeros00 to 23
iMinutes with leading zeros00 to 59
sSeconds with leading zeros00 to 59
uMilliseconds (3 digits)e.g., 000, 123, 239
UUNIX Timestamp (seconds)e.g., 1559648183
Timezone----
ODifference to Greenwich time (GMT) in hourse.g., +0200
PDifference to Greenwich time (GMT) with colon between hours and minutese.g., +02:00
TTimezone abbreviatione.g., UTC, GMT, CST
Date----
cISO 8601 datee.g., 2004-02-12T15:19:21+00:00
rRFC 822 formatted datee.g., Thu, 21 Dec 2000 16:01:07 +0200