- Create a datetimeobject with the UTC time zone info.
- Convert the previous datetimeobject withastimezonemethod.
Here is a example that convert 2025-01-01T00:00Z to your local time.
from datetime import datetime
from zoneinfo import ZoneInfo
utc = datetime(2025, 1, 1, 0, 0, tzinfo=ZoneInfo("UTC"))
localtime = utc.astimezone(tz=ZoneInfo("localtime"))
Note
On Windows and some minimum container environment, installing tzdata pakage might be required.
![[python] convert UTC to your local time with standard libs.](https://media2.dev.to/dynamic/image/width=1000,height=500,fit=cover,gravity=auto,format=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwtopvn2ub9eh696av9fp.png)
