Return a new datetime (or timeval) object with new time zone information. Note that the proper time does not change, only the time zone will change.
See time_zones_info() for a list of all available time zones.
If zone information is given using a fixed offset (+hh[mm]
or -hh[mm]
), then the new datetime
object has no proper time zone information and thus has no
day-light-saving information.
This function does not generate a change.
datetime.to(zone)
Argument | Type | Description |
---|---|---|
zone |
str (required) |
May be a time zone like Europe/Amsterdam , UTC or the format +hh[mm] / -hh[mm] . |
Returns a new datetime
(or timeval
) object.
This code uses
to()
as an example:
datetime('2020-12-10T16:08:24Z').to('Europe/Kyiv');
Return value in JSON format
"2020-12-10T18:08:24+0200"