Skip to main content

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

TypeDescription
stringThe lowercase three-letter abbreviation of the month

c()

@classmethod
def c() - > string

ISO 8601 Format Example : '2008-01-02T10:30:00.000123'

Returns

TypeDescription
stringThe 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

TypeDescription
stringThe zero-padded day of the month

D()

@classmethod
def D() - > string

Day of the week, textual, 3 letters; e.g. 'Fri'

Returns

TypeDescription
stringThe 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

TypeDescription
stringThe alternative or localized month name

F()

@classmethod
def F() - > string

Month, textual, long; e.g. 'January'

Returns

TypeDescription
stringThe full textual name of the month

I()

@classmethod
def I() - > string

'1' if daylight saving time, '0' otherwise.

Returns

TypeDescription
stringA 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

TypeDescription
integerThe day of the month as an integer

l()

@classmethod
def l() - > string

Day of the week, textual, long; e.g. 'Friday'

Returns

TypeDescription
stringThe 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

TypeDescription
booleanTrue if the year is a leap year, False otherwise

m()

@classmethod
def m() - > string

Month; i.e. '01' to '12'

Returns

TypeDescription
stringThe zero-padded numeric month

M()

@classmethod
def M() - > string

Month, textual, 3 letters; e.g. 'Jan'

Returns

TypeDescription
stringThe title-cased three-letter abbreviation of the month

n()

@classmethod
def n() - > integer

Month without leading zeros; i.e. '1' to '12'

Returns

TypeDescription
integerThe numeric month as an integer

N()

@classmethod
def N() - > string

Month abbreviation in Associated Press style. Proprietary extension.

Returns

TypeDescription
stringThe month abbreviation following AP style guidelines

o()

@classmethod
def o() - > integer

ISO 8601 year number matching the ISO week number (W)

Returns

TypeDescription
integerThe 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

TypeDescription
stringThe 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

TypeDescription
stringThe 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

TypeDescription
integerThe 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

TypeDescription
integerThe 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

TypeDescription
integerThe 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

TypeDescription
integerThe ISO week number as an integer

y()

@classmethod
def y() - > string

Year, 2 digits with leading zeros; e.g. '99'.

Returns

TypeDescription
stringThe two-digit representation of the year

Y()

@classmethod
def Y() - > string

Year, 4 digits with leading zeros; e.g. '1999'.

Returns

TypeDescription
stringThe four-digit representation of the year

z()

@classmethod
def z() - > integer

Day of the year, i.e. 1 to 366.

Returns

TypeDescription
integerThe ordinal day of the year