Parse timestamps with mixed UTC offsets using pd.to_datetime(..., utc=True). The result puts the records on one time scale so you can sort them and compare elapsed times. Convert to the time zone your report uses before grouping events by day.

Consider a fictional support log with four records. Two timestamps show 1:15 a.m. on the same date, but their offsets differ by an hour. Keeping the offsets lets us put those events in order and assign each event to the right New York reporting date.

On November 1, 2026, 01:15 with offset minus four hours is 05:15 UTC. The same wall clock time with offset minus five hours is 06:15 UTC, one hour later.
Two entries display 01:15 on the same date. Their explicit offsets place them one hour apart in UTC. All records are hypothetical.Credit: MathBlog

1. Keep the source text and check for offsets

Copy the blocks in order into the same Python session. The data are included as text. The example was tested with Python 3.11.3 and pandas 2.3.3.

from io import StringIO

import pandas as pd

csv_data = """event,occurred_at
B,2026-11-01T01:15:00-05:00
C,2026-11-01T02:30:00Z
A,2026-11-01T01:15:00-04:00
D,2026-11-01T08:00:00+01:00"""

events = pd.read_csv(StringIO(csv_data), dtype={"occurred_at": "string"})
source = events["occurred_at"].str.strip()

feed_shape = r"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:Z|[+-]\d{2}:\d{2})"
has_offset = source.str.fullmatch(feed_shape, na=False)
if not has_offset.all():
    bad_events = events.loc[~has_offset, "event"].tolist()
    raise ValueError(f"Check timestamp format or missing offset for {bad_events}")

The check matches the format used in this feed. Each record needs a date, a time to the second, and an offset such as -04:00 or the UTC marker Z. The timestamp parser in the next step checks whether the matched text represents a valid date and time. Keep the source column so you can trace a result back to the original log.

A missing offset matters. With utc=True, pandas interprets a timestamp that has no offset as already in UTC. If your feed uses local clock times, that assumption can move an event by hours.

2. Parse to a common timeline

events["time_utc"] = pd.to_datetime(
    source, format="ISO8601", errors="raise", utc=True
)
events = events.sort_values("time_utc")

instant_by_event = events.set_index("event")["time_utc"]
gap = instant_by_event["B"] - instant_by_event["A"]
print(gap)

A has an offset of four hours behind UTC, so 01:15 becomes 05:15 UTC. B is five hours behind UTC, so its 01:15 becomes 06:15 UTC. The code prints 0 days 01:00:00. Comparing only the two clock readings would miss the hour between them.

Sort on the parsed column. The offsets are already accounted for there, so the rows follow the order of the actual events.

3. Convert before counting events per local day

new_york_time = events["time_utc"].dt.tz_convert("America/New_York")

events["report_day"] = new_york_time.dt.strftime("%Y-%m-%d")
events["time_in_new_york"] = new_york_time.dt.strftime("%Y-%m-%d %H:%M %z")
events["utc_label"] = events["time_utc"].dt.strftime("%Y-%m-%d %H:%M")

print(events[["event", "utc_label", "time_in_new_york"]].to_string(index=False))
print(events.groupby("report_day").size().to_string())
Expected event order and local display values. The offset column suffix uses the compact form, such as -0400 for -04:00.
Event UTC time New York time and offset
C 2026-11-01 02:30 2026-10-31 22:30 -0400
A 2026-11-01 05:15 2026-11-01 01:15 -0400
B 2026-11-01 06:15 2026-11-01 01:15 -0500
D 2026-11-01 07:00 2026-11-01 02:00 -0500

C occurred on November 1 in UTC, but it was still October 31 in New York. The New York report has one event on October 31 and three on November 1. A UTC-day report would put all four on November 1. Pick the time zone that defines the day in your reporting rules, and keep UTC for elapsed-time calculations.

Handle local clock times separately

If an export contains local times without offsets, find the source time zone first. After parsing the local values, dt.tz_localize() assigns that time zone. Its default behavior raises on ambiguous or nonexistent local times. At the autumn clock change, one local hour repeats. In spring, another can be skipped. Use an offset or other source evidence to resolve ambiguous rows before converting them to UTC.

A single offset identifies how one record relates to UTC. A named time zone also supplies the rules for converting other dates. The report uses America/New_York so its display can reflect the change from -0400 to -0500.

For a related reporting workflow, see how to inspect missing values in pandas before dropping or filling records that need review.

Further reading