DateFormat
This class provides a comprehensive set of methods for formatting date and time objects into various string representations. It supports standard formats like ISO 8601 and RFC 5322, as well as specific components such as textual month names, weekday abbreviations, and English ordinal suffixes. The class also handles time-specific data including Unix timestamps, leap year calculations, and daylight saving time status.
Methods
b()
@classmethod
def b() - > string
Month, textual, 3 letters, lowercase; e.g. 'jan'
Returns
| Type | Description |
|---|---|
string | The lowercase three-letter abbreviation of the month |
c()
@classmethod
def c() - > string
ISO 8601 Format Example : '2008-01-02T10:30:00.000123'
Returns
| Type | Description |
|---|---|
string | The date and time formatted according to the ISO 8601 standard |
d()
@classmethod
def d() - > string
Day of the month, 2 digits with leading zeros; i.e. '01' to '31'
Returns
| Type | Description |
|---|---|
string | The zero-padded day of the month |
D()
@classmethod
def D() - > string
Day of the week, textual, 3 letters; e.g. 'Fri'
Returns
| Type | Description |
|---|---|
string | The three-letter abbreviation of the day of the week |
E()
@classmethod
def E() - > string
Alternative month names as required by some locales. Proprietary extension.
Returns
| Type | Description |
|---|---|
string | The alternative or localized month name |
F()
@classmethod
def F() - > string
Month, textual, long; e.g. 'January'
Returns
| Type | Description |
|---|---|
string | The full textual name of the month |
I()
@classmethod
def I() - > string
'1' if daylight saving time, '0' otherwise.
Returns
| Type | Description |
|---|---|
string | A string '1' if DST is active, '0' if not, or an empty string if no timezone is set |
j()
@classmethod
def j() - > integer
Day of the month without leading zeros; i.e. '1' to '31'
Returns
| Type | Description |
|---|---|
integer | The day of the month as an integer |
l()
@classmethod
def l() - > string
Day of the week, textual, long; e.g. 'Friday'
Returns
| Type | Description |
|---|---|
string | The full textual name of the day of the week |
L()
@classmethod
def L() - > boolean
Boolean for whether it is a leap year; i.e. True or False
Returns
| Type | Description |
|---|---|
boolean | True if the year is a leap year, False otherwise |
m()
@classmethod
def m() - > string
Month; i.e. '01' to '12'
Returns
| Type | Description |
|---|---|
string | The zero-padded numeric month |
M()
@classmethod
def M() - > string
Month, textual, 3 letters; e.g. 'Jan'
Returns
| Type | Description |
|---|---|
string | The title-cased three-letter abbreviation of the month |
n()
@classmethod
def n() - > integer
Month without leading zeros; i.e. '1' to '12'
Returns
| Type | Description |
|---|---|
integer | The numeric month as an integer |
N()
@classmethod
def N() - > string
Month abbreviation in Associated Press style. Proprietary extension.
Returns
| Type | Description |
|---|---|
string | The month abbreviation following AP style guidelines |
o()
@classmethod
def o() - > integer
ISO 8601 year number matching the ISO week number (W)
Returns
| Type | Description |
|---|---|
integer | The ISO 8601 year which may differ from the calendar year during week overlaps |
r()
@classmethod
def r() - > string
RFC 5322 formatted date; e.g. 'Thu, 21 Dec 2000 16:01:07 +0200'
Returns
| Type | Description |
|---|---|
string | The date and time formatted for use in internet message headers |
S()
@classmethod
def S() - > string
English ordinal suffix for the day of the month, 2 characters; i.e. 'st', 'nd', 'rd' or 'th'.
Returns
| Type | Description |
|---|---|
string | The two-character ordinal suffix corresponding to the day of the month |
t()
@classmethod
def t() - > integer
Number of days in the given month; i.e. '28' to '31'
Returns
| Type | Description |
|---|---|
integer | The total count of days in the current month |
U()
@classmethod
def U() - > integer
Seconds since the Unix epoch (January 1 1970 00:00:00 GMT)
Returns
| Type | Description |
|---|---|
integer | The Unix timestamp representing the date and time |
w()
@classmethod
def w() - > integer
Day of the week, numeric, i.e. '0' (Sunday) to '6' (Saturday)
Returns
| Type | Description |
|---|---|
integer | The numeric day of the week where 0 is Sunday |
W()
@classmethod
def W() - > integer
ISO-8601 week number of year, weeks starting on Monday
Returns
| Type | Description |
|---|---|
integer | The ISO week number as an integer |
y()
@classmethod
def y() - > string
Year, 2 digits with leading zeros; e.g. '99'.
Returns
| Type | Description |
|---|---|
string | The two-digit representation of the year |
Y()
@classmethod
def Y() - > string
Year, 4 digits with leading zeros; e.g. '1999'.
Returns
| Type | Description |
|---|---|
string | The four-digit representation of the year |
z()
@classmethod
def z() - > integer
Day of the year, i.e. 1 to 366.
Returns
| Type | Description |
|---|---|
integer | The ordinal day of the year |