isodate

raw JSON →
0.7.2 verified Tue May 12 auth: no python install: verified quickstart: verified

An ISO 8601 date/time/duration parser and formatter. Current version: 0.7.2, released on October 8, 2024. Maintained with a release cadence of approximately one year between major versions.

pip install isodate
error ImportError: No module named 'isodate'
cause The 'isodate' library is not installed in your Python environment.
fix
pip install isodate
error isodate.isoerror.ISO8601Error: Unrecognised ISO 8601 date format: 'YOUR_STRING_HERE'
cause The input string provided to an 'isodate' parsing function (e.g., parse_datetime, parse_date, parse_duration) does not strictly adhere to a recognized ISO 8601 format.
fix
Ensure the date/time/duration string is in a valid ISO 8601 format, such as 'YYYY-MM-DDTHH:MM:SSZ' for datetime or 'P1Y2M3DT4H5M6S' for duration. Refer to the 'isodate' documentation for supported formats.
error AttributeError: module 'isodate' has no attribute 'ISO8601Error'
cause The 'ISO8601Error' exception is not directly available under the top-level 'isodate' module; it is located within the 'isodate.isoerror' submodule.
fix
Import 'ISO8601Error' from 'isodate.isoerror' like this: from isodate.isoerror import ISO8601Error
breaking Fractional seconds are truncated to microseconds (always round down).
fix Ensure input strings have fractional seconds within microsecond precision.
breaking Python versions prior to 3.7 are no longer supported.
fix Upgrade to Python 3.7 or later.
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.01s 17.9M
3.10 slim (glibc) - - 0.01s 18M
3.11 alpine (musl) - - 0.02s 19.8M
3.11 slim (glibc) - - 0.02s 20M
3.12 alpine (musl) - - 0.01s 11.6M
3.12 slim (glibc) - - 0.01s 12M
3.13 alpine (musl) - - 0.01s 11.3M
3.13 slim (glibc) - - 0.01s 12M
3.9 alpine (musl) - - 0.01s 17.4M
3.9 slim (glibc) - - 0.01s 18M

Parse an ISO 8601 date-time string into a Python datetime object.

from isodate import parse_datetime

# Parse an ISO 8601 date-time string
iso_string = '2024-10-08T14:30:00'
parsed_datetime = parse_datetime(iso_string)
print(parsed_datetime)