Option: isoformat()

Python's datetime does not support the military timezone suffixes like 'Z' suffix for UTC. The following simple string replacement does the trick:

In [1]: import datetime

In [2]: d = datetime.datetime(2014, 12, 10, 12, 0, 0)

In [3]: str(d).replace('+00:00', 'Z')
Out[3]: '2014-12-10 12:00:00Z'

str(d) is essentially the same as d.isoformat(sep=' ')

See: Datetime, Python Standard Library

Option: strftime()

Or you could use strftime to achieve the same effect:

In [4]: d.strftime('%Y-%m-%dT%H:%M:%SZ')
Out[4]: '2014-12-10T12:00:00Z'

Note: This option works only when you know the date specified is in UTC.

See: datetime.strftime()


Additional: Human Readable Timezone

Going further, you may be interested in displaying human readable timezone information, pytz with strftime %Z timezone flag:

In [5]: import pytz

In [6]: d = datetime.datetime(2014, 12, 10, 12, 0, 0, tzinfo=pytz.utc)

In [7]: d
Out[7]: datetime.datetime(2014, 12, 10, 12, 0, tzinfo=<UTC>)

In [8]: d.strftime('%Y-%m-%d %H:%M:%S %Z')
Out[8]: '2014-12-10 12:00:00 UTC'
Answer from Manav Kataria on Stack Overflow
Top answer
1 of 14
189

Option: isoformat()

Python's datetime does not support the military timezone suffixes like 'Z' suffix for UTC. The following simple string replacement does the trick:

In [1]: import datetime

In [2]: d = datetime.datetime(2014, 12, 10, 12, 0, 0)

In [3]: str(d).replace('+00:00', 'Z')
Out[3]: '2014-12-10 12:00:00Z'

str(d) is essentially the same as d.isoformat(sep=' ')

See: Datetime, Python Standard Library

Option: strftime()

Or you could use strftime to achieve the same effect:

In [4]: d.strftime('%Y-%m-%dT%H:%M:%SZ')
Out[4]: '2014-12-10T12:00:00Z'

Note: This option works only when you know the date specified is in UTC.

See: datetime.strftime()


Additional: Human Readable Timezone

Going further, you may be interested in displaying human readable timezone information, pytz with strftime %Z timezone flag:

In [5]: import pytz

In [6]: d = datetime.datetime(2014, 12, 10, 12, 0, 0, tzinfo=pytz.utc)

In [7]: d
Out[7]: datetime.datetime(2014, 12, 10, 12, 0, tzinfo=<UTC>)

In [8]: d.strftime('%Y-%m-%d %H:%M:%S %Z')
Out[8]: '2014-12-10 12:00:00 UTC'
2 of 14
90

Python datetime objects don't have time zone info by default, and without it, Python actually violates the ISO 8601 specification (if no time zone info is given, assumed to be local time). You can use the pytz package to get some default time zones, or directly subclass tzinfo yourself:

from datetime import datetime, tzinfo, timedelta
class simple_utc(tzinfo):
    def tzname(self,**kwargs):
        return "UTC"
    def utcoffset(self, dt):
        return timedelta(0)

Then you can manually add the time zone info to utcnow():

>>> datetime.utcnow().replace(tzinfo=simple_utc()).isoformat()
'2014-05-16T22:51:53.015001+00:00'

Note that this DOES conform to the ISO 8601 format, which allows for either Z or +00:00 as the suffix for UTC. Note that the latter actually conforms to the standard better, with how time zones are represented in general (UTC is a special case.)

🌐
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.
Discussions

Need help removing time zone from datetime
Variable = df.replace(tzinfo=None) Formatted_datetime = Variable.strftime("%Y-%m-%d %H:%M:%S More on reddit.com
🌐 r/learnpython
8
4
February 28, 2024
Deprecating `utcnow` and `utcfromtimestamp` - Core Development - Discussions on Python.org
Previously, we have documented that utcnow and utcfromtimestamp should not be used, but we didn’t go so far as to actually deprecate them, and I wrote a whole article about how you shouldn’t use them. The main reason I had for not deprecating them at the time was that .utcnow() is faster ... More on discuss.python.org
🌐 discuss.python.org
8
April 26, 2023
PSA: As of Python 3.11, `datetime.fromisoformat` supports most ISO 8601 formats (notably the "Z" suffix)
Fucking finally. More on reddit.com
🌐 r/Python
34
290
August 28, 2023
Solved--Why does python not support the `Z` suffix for UTC timezone?
We can put Z at the end to express zero timezone according to ISO8601. [ISO 8601 - Wikipedia](https://iso8601 introduction) “2024-01-01T02:32:21Z” is the right format in ISO8601. >>> s = "2024-01-01T02:32:21Z" >>> dt … More on discuss.python.org
🌐 discuss.python.org
0
0
January 1, 2024
🌐
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).
🌐
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

🌐
Crown
ccgit.crown.edu › cyber-reels › pythons-isoformat-date-and-time-without-the-timezone-hassle-1767647371
Python's Isoformat: Date And Time Without The Timezone Hassle
January 6, 2026 - You can use isoformat() to generate a clean string without timezone information. This is perfect when you need a simple representation for storage, display, or data exchange where timezone details aren’t essential.
🌐
Python.org
discuss.python.org › core development
Deprecating `utcnow` and `utcfromtimestamp` - Core Development - Discussions on Python.org
April 26, 2023 - Previously, we have documented that utcnow and utcfromtimestamp should not be used, but we didn’t go so far as to actually deprecate them, and I wrote a whole article about how you shouldn’t use them. The main reason I had for not deprecating them at the time was that .utcnow() is faster than .now(datetime.UTC), and if you are immediately converting the datetime to a string, like datetime.utcnow().isoformat(), there’s no danger.
🌐
Note.nkmk.me
note.nkmk.me › home › python
Convert Between Isoformat String and datetime in Python | note.nkmk.me
August 22, 2023 - As mentioned above, use fromisoformat() for Python 3.11 and later, and strptime() for earlier versions. s_basic = '20230401T050030.001000' print(datetime.datetime.fromisoformat(s_basic).isoformat()) # 2023-04-01T05:00:30.001000 · source: ...
🌐
GitHub
github.com › fastapi › fastapi › discussions › 9887
Converting datetime to UTC and ISO format ends up with Z instead of +00:00 · fastapi/fastapi · Discussion #9887
from fastapi import FastAPI from fastapi.testclient import TestClient from datetime import datetime, date import uvicorn import pytz import pytest app = FastAPI() @app.get("/") async def root(): test_date = datetime.now() test_date_tz = (datetime.now().replace(tzinfo=pytz.UTC)).isoformat() return { "date": test_date, "date_tz": test_date_tz } client = TestClient(app) def test_date(): response = client.get("/") print( response.json()) test_date = datetime.strptime(response.json()["date_tz"], "%Y-%m-%dT%H:%M:%S.%f+00:00").date() print(test_date)
Author   fastapi
Find elsewhere
🌐
Python
bugs.python.org › issue46614
Issue 46614: Add option to output UTC datetimes as "Z" in `.isoformat()` - Python tracker
This issue tracker has been migrated to GitHub, and is currently read-only. For more information, see the GitHub FAQs in the Python's Developer Guide · This issue has been migrated to GitHub: https://github.com/python/cpython/issues/90772
🌐
Reddit
reddit.com › r/python › psa: as of python 3.11, `datetime.fromisoformat` supports most iso 8601 formats (notably the "z" suffix)
r/Python on Reddit: PSA: As of Python 3.11, `datetime.fromisoformat` supports most ISO 8601 formats (notably the "Z" suffix)
August 28, 2023 -

In Python 3.10 and earlier, datetime.fromisoformat only supported formats outputted by datetime.isoformat. This meant that many valid ISO 8601 strings could not be parsed, including the very common "Z" suffix (e.g. 2000-01-01T00:00:00Z).

I discovered today that 3.11 supports most ISO 8601 formats. I'm thrilled: I'll no longer have to use a third-party library to ingest ISO 8601 and RFC 3339 datetimes. This was one of my biggest gripes with Python's stdlib.

It's not 100% standards compliant, but I think the exceptions are pretty reasonable:

  • Time zone offsets may have fractional seconds.

  • The T separator may be replaced by any single unicode character.

  • Ordinal dates are not currently supported.

  • Fractional hours and minutes are not supported.

https://docs.python.org/3/library/datetime.html#datetime.datetime.fromisoformat

🌐
Towards Data Science
towardsdatascience.com › home › latest › time travel made easy: a comprehensive guide to python datetime
Time Travel Made Easy: A Comprehensive Guide to Python Datetime | Towards Data Science
January 24, 2025 - Once the timezone is attached to the datetime series or index, you can perform datetime operations that require timezone information such as converting the column to a specific timezone (i.e. Singapore). Left vs Right Output: Without vs With converting to a specific Timezone
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-make-a-timezone-aware-datetime-object-in-python
How to make a timezone aware datetime object in Python - GeeksforGeeks
July 23, 2025 - Explanation: ZoneInfo("Asia/Kolkata") get the real timezone for IST, then datetime.now() returns the current time with correct daylight saving and timezone info as a timezone-aware datetime.
🌐
Python.org
discuss.python.org › python help
Solved--Why does python not support the `Z` suffix for UTC timezone? - Python Help - Discussions on Python.org
January 1, 2024 - We can put Z at the end to express zero timezone according to ISO8601. [ISO 8601 - Wikipedia](https://iso8601 introduction) “2024-01-01T02:32:21Z” is the right format in ISO8601. >>> s = "2024-01-01T02:32:21Z" >>> dt …
🌐
Folkstalk
folkstalk.com › home › technology articles collection
Technology Articles Collection
July 3, 2025 - Skip to content · Technology Articles Collection · Coming Soon · Popular Posts · Joiner Transformation in Informatica · Dell Boomi Architecture Overview · Transaction Control Transformation in Informatica · Awk Command in Unix With Examples · Salesforce Batch Apex Job With Examples ...
🌐
Codegrepper
codegrepper.com › code-examples › javascript › moment+js+iso+format+without+timezone
moment date without timezone - Code Examples & Solutions
August 30, 2020 - Register to vote on and add code examples. Join our developer community to improve your dev skills and code like a boss · Help us improve our code examples by registering to vote on and add answers. Join our developer community to improve your dev skills and code like a boss · By continuing, ...