Skip to main content

date_format

Format a datetime.date or datetime.datetime object using a localizable format.

If use_l10n is provided and is not None, that will force the value to be localized (or not), otherwise it's always localized.

def date_format(
value: datetime.date | datetime.datetime,
format: string = None,
use_l10n: boolean = None
) - > string

Format a datetime.date or datetime.datetime object using a localizable format.

Parameters

NameTypeDescription
value`datetime.datedatetime.datetime`
formatstring = NoneThe format string or named format (e.g., 'DATE_FORMAT') to apply; defaults to the system DATE_FORMAT if not provided.
use_l10nboolean = NoneA flag to force localization on or off; if None, the value is always localized.

Returns

TypeDescription
stringThe formatted date string based on the specified format and localization settings.