Python Datetime Format Converter

Python's `datetime` module produces two canonical string forms: `isoformat()` (`2026-08-13T14:30:00` or with offset) and `time.ctime()` (`Thu Aug 13 14:30:00 2026`). Many bugs come from assuming these match ISO 8601 or RFC 2822 exactly — they do not.

This converter outputs your date-time in both Python forms so you can predict what `datetime.now().isoformat()` and `datetime.fromtimestamp(x).ctime()` will print, and match them when parsing logs or API payloads.

Timezone:
Enter a date-time above to see the conversion results.

Python Datetime Format Converter Quick Reference

FormatPattern / DescriptionExample 1Example 2
Python isoformat()ISO with microseconds2026-08-13T14:30:00.000000Z2026-01-01T00:00:00.000000Z
Python ctimectime() / asctime()Thu Aug 13 14:30:00 2026Thu Jan 01 00:00:00 2026

* Examples are rendered in UTC for the fixed sample instants above.

When to Use Python Datetime Format

Log parsing with Python

Python services log with `isoformat()` or `ctime()` by default. Convert samples to verify your regex/parser handles the exact string shape.

API payload design

Decide whether your Django/FastAPI serializers emit naive or offset ISO strings, and verify what clients will receive.

datetime.fromisoformat compatibility

Python 3.11+ `fromisoformat` parses most ISO shapes, but strictness varies by version. Test candidate strings here first.

Frequently Asked Questions

What does Python isoformat() output?

`YYYY-MM-DDTHH:MM:SS` for naive datetimes (`2026-08-13T14:30:00`) or with `+HH:MM`/`Z` when timezone-aware (`2026-08-13T14:30:00+00:00`).

What does Python ctime() output?

The C library `ctime` form: `Thu Aug 13 14:30:00 2026` — a fixed 24-character string without a timezone offset.

How do I get milliseconds in Python isoformat?

`isoformat(sep="T", timespec="milliseconds")` produces `2026-08-13T14:30:00.123`. Default `isoformat()` omits microseconds when they are zero.

Why does Python print different dates than my JavaScript code?

Likely timezone handling: Python naive datetimes are "wall clock", JS `Date` is epoch-based and renders per the runtime zone. Always convert to UTC before comparing.

Related Time Format Converters

All Format Guides

Need to Convert Between All Formats?

Use the main Time Format Converter for instant conversion across 100+ formats — epoch, ISO 8601, RFC 3339, SQL datetime, military time and more in one click.

Open Time Format Converter