To remove a timezone (tzinfo) from a datetime object:

# dt_tz is a datetime.datetime object
dt = dt_tz.replace(tzinfo=None)

If you are using a library like arrow, then you can remove timezone by simply converting an arrow object to to a datetime object, then doing the same thing as the example above.

# <Arrow [2014-10-09T10:56:09.347444-07:00]>
arrowObj = arrow.get('2014-10-09T10:56:09.347444-07:00')

# datetime.datetime(2014, 10, 9, 10, 56, 9, 347444, tzinfo=tzoffset(None, -25200))
tmpDatetime = arrowObj.datetime

# datetime.datetime(2014, 10, 9, 10, 56, 9, 347444)
tmpDatetime = tmpDatetime.replace(tzinfo=None)

Why would you do this? One example is that mysql does not support timezones with its DATETIME type. So using ORM's like sqlalchemy will simply remove the timezone when you give it a datetime.datetime object to insert into the database. The solution is to convert your datetime.datetime object to UTC (so everything in your database is UTC since it can't specify timezone) then either insert it into the database (where the timezone is removed anyway) or remove it yourself. Also note that you cannot compare datetime.datetime objects where one is timezone aware and another is timezone naive.

##############################################################################
# MySQL example! where MySQL doesn't support timezones with its DATETIME type!
##############################################################################

arrowObj = arrow.get('2014-10-09T10:56:09.347444-07:00')

arrowDt = arrowObj.to("utc").datetime

# inserts datetime.datetime(2014, 10, 9, 17, 56, 9, 347444, tzinfo=tzutc())
insertIntoMysqlDatabase(arrowDt)

# returns datetime.datetime(2014, 10, 9, 17, 56, 9, 347444)
dbDatetimeNoTz = getFromMysqlDatabase()

# cannot compare timzeone aware and timezone naive
dbDatetimeNoTz == arrowDt # False, or TypeError on python versions before 3.3

# compare datetimes that are both aware or both naive work however
dbDatetimeNoTz == arrowDt.replace(tzinfo=None) # True
Answer from user1094786 on Stack Overflow
Top answer
1 of 1
389

To remove a timezone (tzinfo) from a datetime object:

# dt_tz is a datetime.datetime object
dt = dt_tz.replace(tzinfo=None)

If you are using a library like arrow, then you can remove timezone by simply converting an arrow object to to a datetime object, then doing the same thing as the example above.

# <Arrow [2014-10-09T10:56:09.347444-07:00]>
arrowObj = arrow.get('2014-10-09T10:56:09.347444-07:00')

# datetime.datetime(2014, 10, 9, 10, 56, 9, 347444, tzinfo=tzoffset(None, -25200))
tmpDatetime = arrowObj.datetime

# datetime.datetime(2014, 10, 9, 10, 56, 9, 347444)
tmpDatetime = tmpDatetime.replace(tzinfo=None)

Why would you do this? One example is that mysql does not support timezones with its DATETIME type. So using ORM's like sqlalchemy will simply remove the timezone when you give it a datetime.datetime object to insert into the database. The solution is to convert your datetime.datetime object to UTC (so everything in your database is UTC since it can't specify timezone) then either insert it into the database (where the timezone is removed anyway) or remove it yourself. Also note that you cannot compare datetime.datetime objects where one is timezone aware and another is timezone naive.

##############################################################################
# MySQL example! where MySQL doesn't support timezones with its DATETIME type!
##############################################################################

arrowObj = arrow.get('2014-10-09T10:56:09.347444-07:00')

arrowDt = arrowObj.to("utc").datetime

# inserts datetime.datetime(2014, 10, 9, 17, 56, 9, 347444, tzinfo=tzutc())
insertIntoMysqlDatabase(arrowDt)

# returns datetime.datetime(2014, 10, 9, 17, 56, 9, 347444)
dbDatetimeNoTz = getFromMysqlDatabase()

# cannot compare timzeone aware and timezone naive
dbDatetimeNoTz == arrowDt # False, or TypeError on python versions before 3.3

# compare datetimes that are both aware or both naive work however
dbDatetimeNoTz == arrowDt.replace(tzinfo=None) # True
🌐
Reddit
reddit.com › r/learnpython › need help removing time zone from datetime
r/learnpython on Reddit: Need help removing time zone from datetime
February 28, 2024 -

So i have a script that pulls some stuff from Sharepoint. One of the fields is the timestamp that an entry was made into the Sharepoint list. When pulling it from the API it is returned in the following format:

ENTERED_TM
2024-02-28T17:48:43Z

The datatype of this field when returned from the API is Object. I want to drop the time zone stuff so i just have YYYY-MM-DD H:M:S.

I've tried a couple different things:

First I convert it to datetime with cleaned_df["ENTERED_TM"] = pd.to_datetime(cleaned_df["ENTERED_TM"])

Then i've tried 2 ways of dropping the time zone cleaned_df["ENTERED_TM"].dt.tz_convert(None) and cleaned_df["ENTERED_TM"].dt.tz_localize(None)

Both of those leave me this:

ENTERED_TM
2024-02-28 17:48:43+00:00

Any help would be appreciated

Discussions

Get now() with local system timezone without knowing the timezone first - Ideas - Discussions on Python.org
Currently now() and now(None) would return a naive datetime in the local system timezone (inherited from long ago), while now(tz) gets you an aware datetime in the timezone tz. What’s missing though is a way to get an aware datetime in the local system timezone. More on discuss.python.org
🌐 discuss.python.org
8
January 11, 2023
Make specific DateTimeFields without timezone
My Django project correctly has timezones enabled and it always stores times with timezone in the Postgres database. There is just one table my project needs to access that is managed by another application. To access this other table I have configured a second database, a database router, ... More on forum.djangoproject.com
🌐 forum.djangoproject.com
1
0
January 17, 2023
python - Why does datetime.datetime.utcnow() not contain timezone information? - Stack Overflow
If you want to get LOCAL timezone aware datetime object without using any extra module then just add astimezone(): d.astimezone() 2020-09-18T14:05:33.72Z+00:00 ... Julien Danjou wrote a good article explaining why you should never deal with timezones. An excerpt: Indeed, Python datetime API ... More on stackoverflow.com
🌐 stackoverflow.com
What's up with the messy datetime/timezone support in the standard library?
Why does working with datetime and timezones sucks so much. Because working with datetime and timezones sucks so much in general. https://www.youtube.com/watch?v=-5wpm-gesOY It's hard as fuck to write a complete, one size fits all solution so you get libs that recognize weaknesses of existing solutions and try to plug holes and the cycle continues. More on reddit.com
🌐 r/learnpython
7
9
May 28, 2015
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-remove-timezone-information-from-datetime-object-in-python
How to remove timezone information from DateTime object in Python - GeeksforGeeks
July 23, 2025 - If you're using the pytz library, you can localize your naive datetime to a specific timezone, then strip the timezone info using replace(tzinfo=None). This is useful in legacy code or when you need timezone support beyond the standard library.
🌐
Finxter
blog.finxter.com › 5-best-ways-to-remove-timezone-from-python-datetime-objects
5 Best Ways to Remove Timezone from Python Datetime Objects – Be on the Right Side of Change
The code creates an aware datetime object and uses aware_datetime.astimezone(None) to convert it to a naive datetime in the local timezone. Method 1: Replace with Tzinfo=None. Strength: Straightforward use of Python’s standard library.
🌐
DataScientYst
datascientyst.com › remove-timezone-datetime-column-pandas
How to Remove Timezone from a DateTime Column in Pandas
February 25, 2022 - 0 2021-08-01 13:23:41.775854 1 2021-08-02 13:24:12.432523 2 2021-08-03 13:22:59.123512 Name: time_tz, dtype: datetime64[ns] Now you can use this column without getting the errors mentioned above. Another option to deal with TimeZone info is by using the method: .dt.tz_convert('UTC').
🌐
Python.org
discuss.python.org › ideas
Get now() with local system timezone without knowing the timezone first - Ideas - Discussions on Python.org
January 11, 2023 - Currently now() and now(None) would return a naive datetime in the local system timezone (inherited from long ago), while now(tz) gets you an aware datetime in the timezone tz. What’s missing though is a way to get an aw…
🌐
Astral
docs.astral.sh › ruff › rules › call-datetime-now-without-tzinfo
call-datetime-now-without-tzinfo (DTZ005) | Ruff - Astral Docs
Checks for usages of datetime.datetime.now() that do not specify a timezone. Python datetime objects can be naive or timezone-aware. While an aware object represents a specific moment in time, a naive object does not contain enough information to unambiguously locate itself relative to other ...
🌐
Stack Abuse
stackabuse.com › comparing-datetimes-in-python-with-and-without-timezones
Comparing Datetimes in Python with and without Timezones
August 25, 2021 - date_with_timezone = tz_ny.localize(datetime) print(datetime == date_without_timezone) ... So to compare datetime objects, both objects must both be either naive or aware. In this article, we have discussed ways of comparing both timezone-aware and timezone-naive dates in Python, we have also looked at possible pitfalls that we may encounter when comparing dates and possible workarounds.
Find elsewhere
🌐
Miguel Grinberg
blog.miguelgrinberg.com › post › it-s-time-for-a-change-datetime-utcnow-is-now-deprecated
It's Time For A Change: datetime.utcnow() Is Now Deprecated - miguelgrinberg.com
Note that if you are using Python 3.11 or newer, you can replace datetime.timezone.utc with a shorter datetime.UTC. ... 2023-11-18 11:36:35.137639+00:00 1970-01-01 00:00:00+00:00 2023-11-18 11:36:35.137672 1970-01-01 00:00:00 · You can tell that the first and second lines show aware datetime instances from the +00:00 suffix that indicates that the timezone is 00:00 or UTC. The third and fourth lines show abstract timestamps without a timezone, fully compatible with those returned by the deprecated functions.
🌐
Crown
ccgit.crown.edu › cyber-reels › python-iso-format-handling-datetimes-without-timezones-1767647371
Python ISO Format: Handling Datetimes Without Timezones
January 6, 2026 - The key takeaway here is that replace(tzinfo=None) is your best friend for converting an aware datetime into a naive one, which then allows isoformat() to produce the string you desire without any timezone specifiers. Remember, this process doesn’t alter the actual time value; it just makes the representation naive. If you’re on Python 3.9 or later, you’ve got the fantastic zoneinfo module right in your standard library.
🌐
Python documentation
docs.python.org › 3 › library › datetime.html
datetime — Basic date and time types
If you merely want to remove the timezone object from an aware datetime dt without conversion of date and time data, use dt.replace(tzinfo=None).
🌐
BrowserStack
browserstack.com › home › guide › understanding python datetime astimezone()
Understanding Python DateTime astimezone() | BrowserStack
October 18, 2024 - The naive datetime object (without a time zone) represents 12:00 PM on September 23, 2024. By using pytz.timezone().localize(), the naive time is converted to an aware datetime object in the US/Pacific time zone.
🌐
Duke
fintechpython.pages.oit.duke.edu › jupyternotebooks › 1-Core Python › answers › rq-28-answers.html
Core Python / Dates and Times — Programming for Financial Technology
To create a datetime object representing the current date and time in Python, you can use the now() method of the datetime class from the datetime module. This method returns a datetime object with the current local date and time, but no timezone by default.
🌐
Django Forum
forum.djangoproject.com › using django › forms & apis
Make specific DateTimeFields without timezone - Forms & APIs - Django Forum
January 17, 2023 - My Django project correctly has timezones enabled and it always stores times with timezone in the Postgres database. There is just one table my project needs to access that is managed by another application. To access t…
🌐
Hrekov
hrekov.com › blog › remove-timezone-python
All Possible Ways to Remove Timezone Information from a Python `datetime` Object | Backend APIs, Web Apps, Bots & Automation | Hrekov
November 16, 2025 - 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.
🌐
Majornetwork
majornetwork.net › 2024 › 02 › datetimes-with-timezones-in-python
Datetimes with Timezones in Python – Majornetwork
February 17, 2024 - First, let’s show how the commonly-used plain datetime.datetime.now() gets the local time but does not have a timezone: >>> import datetime >>> now = datetime.datetime.now()
🌐
Fremontleaf
wiki.fremontleaf.org › official-files › python-datetimeisoformat-without-timezone-1767646942
Python Datetime.isoformat() Without Timezone
January 6, 2026 - Use isoformat() directly on naive datetimes. If your datetime object is already naive (meaning it has no tzinfo), just call isoformat() on it. Python will correctly produce a timezone-free string without any extra steps.
🌐
InitialXY
initialxy.com › lesson › 2022 › 03 › 18 › getting-the-right-time-zone-in-python
Getting the Right Time Zone in Python - initialxy
March 18, 2022 - A datetime instance can be created without associating it with a timezone, in which case it’s considered naive. When it is associated with a timezone, then it’s aware. Keep in mind that Python’s built-in datetime.timezone does not contain tz database, so it’s not particularly useful ...
Top answer
1 of 10
387

Note that for Python 3.2 onwards, the datetime module contains datetime.timezone. The documentation for datetime.utcnow() says:

An aware current UTC datetime can be obtained by calling datetime.now(timezone.utc).

So, datetime.utcnow() doesn't set tzinfo to indicate that it is UTC, but datetime.now(datetime.timezone.utc) does return UTC time with tzinfo set.

So you can do:

>>> import datetime
>>> datetime.datetime.now(datetime.timezone.utc)
datetime.datetime(2014, 7, 10, 2, 43, 55, 230107, tzinfo=datetime.timezone.utc)

Since Python 3.11, there also exists datetime.UTC which is equivalent to datetime.timezone.utc. So you can also do datetime.datetime.now(datetime.UTC).

2 of 10
251

That means it is timezone naive, so you can't use it with datetime.astimezone

you can give it a timezone like this

import pytz  # 3rd party: $ pip install pytz

u = datetime.utcnow()
u = u.replace(tzinfo=pytz.utc) #NOTE: it works only with a fixed utc offset

now you can change timezones

print(u.astimezone(pytz.timezone("America/New_York")))

To get the current time in a given timezone, you could pass tzinfo to datetime.now() directly:

#!/usr/bin/env python
from datetime import datetime
import pytz # $ pip install pytz

print(datetime.now(pytz.timezone("America/New_York")))

It works for any timezone including those that observe daylight saving time (DST) i.e., it works for timezones that may have different utc offsets at different times (non-fixed utc offset). Don't use tz.localize(datetime.now()) -- it may fail during end-of-DST transition when the local time is ambiguous.

🌐
Arie Bovenberg
dev.arie.bovenberg.net › blog › python-datetime-pitfalls
Ten Python datetime pitfalls, and what libraries are (not) doing about it | Arie Bovenberg
January 20, 2024 - # This time doesn't exist on this date d = datetime(2023, 3, 26, 2, 30, tzinfo=paris) # No timestamp exists, so it takes another one from the future t = d.timestamp() datetime.fromtimestamp(t, tz=paris) == d # False!? pendulum replaces the current silent behavior with another: it fast-forwards to a valid time without warning. arrow, DateType and heliclockter don’t address this issue · When the clock in a timezone is set backwards, an ambiguity is created.