![Sonarr api](https://loka.nahovitsyn.com/47.jpg)
![convert utc time convert utc time](https://1.bp.blogspot.com/-ApSLc8FPf0Q/Xyf5h-cUA_I/AAAAAAAABqg/KWPAFe88MjI5eLPpLZUo1xIFP1tlV8jDwCLcBGAsYHQ/s1600/UST-local-time-zone-conversion.jpg)
Suppose we have a datetime object that contains the current time in the UTC timezone and has the timezone information. Output: Datetime in UTC Time zone: 09:10:34.300030+00:00ĭatetime in Local Time zone: 14:40:34.300030+05:30 Convert the current UTC datetime to local datetime in python Print('Datetime in Local Time zone: ', local_dt) # Create Datetime object with UTC timezoneĭt_utc = datetime(2021, 10, 4, 9, 10, 34, 300030, tzinfo=pytz.UTC ) For example, from datetime import datetime Instead of string, if you already have the datetime object with UTC timezone, we can convert it directly to a datetime object with a local timezone using astimezone(). Time as string in Local Time zone: 13:48:19 Convert UTC datetime object from local datetime Print('Time as string in Local Time zone: ', local_time_str) Local_time_str = dt_local.strftime(format) Print('Datetime in Local Time zone: ', dt_local)
![convert utc time convert utc time](http://time.unitarium.com/tzs/og/1200pm.jpg)
# Convert timezone of datetime from UTC to local
![convert utc time convert utc time](http://c.tadst.com/gfx/screenshots/tz-conv-help3.png)
Print('Datetime in UTC Time zone: ', dt_utc) # Create datetime object in local timezoneĭt_utc = datetime.strptime(dt_str, format) Let’s see a complete example to convert UTC datetime string to local time i.e. it converts the time in calling datetime to the specified timezone and returns a new datetime object containing it. It returns a new DateTime instance according to the specified time zone parameter tz i.e. The astimezone() function accepts a timezone instance tz as argument.
![Sonarr api](https://loka.nahovitsyn.com/47.jpg)