Skip to main content

One post tagged with "timezone"

timezone tag description

View All Tags

All Possible Ways to Remove Timezone Information from a Python `datetime` Object

· 7 min read
Serhii Hrekov
software engineer, creator, artist, programmer, projects founder

A Python datetime object is considered timezone-aware if its tzinfo attribute is set, and timezone-naive if tzinfo is None. Removing timezone information, or "making it naive," is the process of setting this attribute to None.

The key consideration when stripping the timezone is which time value you want to keep: the time as it was originally represented, or the time converted to a standard reference (like UTC or local time) before stripping the timezone.