Skip to main content

localdate

Convert an aware datetime to local time and return the value's date.

Only aware datetimes are allowed. When value is omitted, it defaults to now().

Local time is defined by the current time zone, unless another time zone is specified.

def localdate(
value: datetime.datetime = None,
timezone: datetime.tzinfo = None
) - > datetime.date

Convert an aware datetime to local time and return the value's date. Only aware datetimes are allowed. When value is omitted, it defaults to now(). Local time is defined by the current time zone, unless another time zone is specified.

Parameters

NameTypeDescription
valuedatetime.datetime = NoneThe aware datetime object to be converted; defaults to the current time if not provided.
timezonedatetime.tzinfo = NoneThe target time zone for the conversion; defaults to the currently active time zone.

Returns

TypeDescription
datetime.dateThe date component of the converted datetime object in the target time zone.