Skip to main content

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.

Method 1: Stripping Timezone Directly (Most Common)

The most direct and efficient way to remove timezone information is using the replace() method, setting the tzinfo attribute to None. This method does not change the hour, minute, or seconds of the datetime object; it simply discards the offset tag.

This method is suitable when you need to preserve the "wall clock time" value, even if the timezone information suggests that time occurred at a different absolute moment in history.

from datetime import datetime, timezone

dt_aware = datetime.now(timezone.utc)
# Example: 2025-11-16 00:00:00+00:00

# Action: Discard the +00:00 offset
dt_naive_same_time = dt_aware.replace(tzinfo=None)

# Result: 2025-11-16 00:00:00 (tzinfo=None)
print(dt_naive_same_time)

Method Effect on Time Value Annotation. dt.replace(tzinfo=None) Time value remains the same (the "wall clock time"). Use this when you need the time string exactly as it is, but without the offset.

Method 2: Stripping Timezone After Converting to a Standard Time

If you need the resultant naive datetime to represent the absolute moment in UTC or your system's local time, you must perform a conversion using astimezone() before stripping the timezone.

A. Converting to Naive UTC Time

This is the recommended approach for databases and logs, as it creates a naive UTC timestamp, which is a standardized, unambiguous format.

from datetime import datetime, timezone
import pytz # Can also use standard library's ZoneInfo or dateutil.tz

# Assume time is 10:00 AM New York (EDT, offset -04:00)
dt_ny_aware = datetime(2025, 11, 15, 10, 0, tzinfo=pytz.timezone('America/New_York'))

# 1. Convert to UTC: 10:00 - 4 hours = 06:00 UTC
dt_utc_aware = dt_ny_aware.astimezone(timezone.utc)

# 2. Strip the Timezone
dt_naive_utc = dt_utc_aware.replace(tzinfo=None)

# Result: 2025-11-15 06:00:00 (tzinfo=None)
print(dt_naive_utc)

Method Effect on Time Value Annotation. dt.astimezone(timezone.utc).replace(tzinfo=None) Time value is adjusted to reflect the UTC time. Recommended practice for consistent storage of datetimes. B. Converting to Naive Local Time

This converts the time to your system's default local timezone before making it naive.

# System Timezone is implicitly used when tz=None is passed
dt_local_aware = dt_ny_aware.astimezone(None)
dt_naive_local = dt_local_aware.replace(tzinfo=None)

Method 3: Using String Formatting and Parsing (Inefficient but Universal)

This method relies on converting the aware datetime to a formatted string that explicitly excludes the timezone offset, and then parsing that string back into a new naive datetime object. This is typically the slowest method and should be avoided unless you are already working with string representations.

from datetime import datetime, timezone

dt_aware = datetime.now(timezone.utc)

# 1. Format the aware datetime to a string, excluding the timezone info
dt_str = dt_aware.strftime("%Y-%m-%d %H:%M:%S.%f")

# 2. Parse the string back into a naive datetime
dt_naive = datetime.strptime(dt_str, "%Y-%m-%d %H:%M:%S.%f")

# Result: A new naive datetime object with the same time string as the input.
print(dt_naive)

Method Effect on Time Value Annotation. strftime() then strptime() Time value remains the same (the "wall clock time"). Slowest method; only use if string serialization is a mandatory intermediate step.

Method 4: Pandas tz_localize(None) (For DataFrames)

If you are working with Pandas DataFrames, the most idiomatic and efficient way to remove timezone information from an entire column (Series) of datetimes is using the .dt.tz_localize(None) method.

import pandas as pd

# df['timestamp'] is a timezone-aware Series
# Example: 2025-11-16 00:00:00+00:00

# Action: Removes the timezone offset, resulting in naive datetimes.
df['timestamp'] = df['timestamp'].dt.tz_localize(None)

# Result: 2025-11-16 00:00:00 (dtype changes from datetime64[ns, UTC] to datetime64[ns])

Method Context Annotation. Series.dt.tz_localize(None) Pandas DataFrames Fastest way to convert an entire column of aware times to naive times while preserving the original time value.

Sources and Further Reading

Python Docs - datetime.replace()

Pandas Docs - Series.dt.tz_localize()

Stack Overflow - Converting timezone-aware datetime to local time in Python