Timestamps in Scraped Data: The Mistakes Everyone Makes

Cover for “Timestamps in Scraped Data: The Mistakes Everyone Makes”: US clock change repeating 01:30 local time, the fields a price row needs and observation windows

5 min read

A price without a reliable time attached to it is an anecdote. Every analysis built on scraped data, from a price index to a MAP violation report, depends on knowing when each value was true. Yet timestamps are where pipelines are sloppiest: local times without zones, one column doing three jobs, and change times that were never actually observed.

Key takeaways

  • Store instants in UTC and keep the source’s local context separately. Never store a local wall-clock time without its zone.
  • Separate the timestamps: when you observed a value, when it became valid in your history, and when it was loaded.
  • When clocks fall back, an hour of local time happens twice. In New York on 1 November 2026, “01:30” means two different instants.
  • You observe states, not changes. A price change is only known to lie between two observations.
  • PostgreSQL’s timestamptz stores an instant, not the offset you gave it.

One column, three meanings

The most common mistake is a single timestamp column that means different things in different rows. For scraped price data, at least three times matter, and they are different:

FieldMeaningSourceStore as
observed_atWhen the response was receivedYour collector’s clock, synchronizedUTC instant
valid_from, valid_toThe interval during which your history says the value heldDerived from observationsUTC instants, half-open interval
loaded_atWhen the row reached the warehouseYour pipelineUTC instant
source_modifiedWhen the site says the content changed (Last-Modified, sitemap lastmod)The site, if it saysUTC instant, nullable
promo_start, promo_endDates the page states for a salePage textLocal date and time plus the zone they refer to

Field names are ours. dbt snapshots use the same pattern for history: dbt_valid_from and dbt_valid_to bound each version of a record, with dbt_valid_to null for the current one.

UTC for instants, zones for context

An observation happened at one instant, whatever clock you read it from. Store that instant in UTC. Then store, separately, the context needed to interpret it: the market’s time zone, the store’s location, the currency. A US retailer’s “sale ends at midnight” means midnight in some zone, usually the retailer’s own or the shopper’s, and the page rarely says which. Record what the page says verbatim, the zone you believe it refers to, and how you decided.

The trap is local time stored without a zone. Twice a year it breaks, and once a year it creates ambiguity that no amount of later cleaning can resolve.

The hour that happens twice

UTC instants on 1 November 2026 mapped to New York time, when daylight saving ends

UTCNew York04:0000:00EDT04:3000:30EDT05:0001:00EDT05:3001:30EDT06:0001:00EST06:3001:30EST07:0002:00EST07:3002:30ESTOrange: two different instants that read 01:30 on a New York wall clock.
Computed with Python’s zoneinfo (IANA time zone database). The same applies to 01:00 to 01:59 local. Graphic: JsonEngine.

On 1 November 2026, US daylight saving time ends at 02:00 local time and New York clocks go back to 01:00. Everything from 01:00 to 01:59 happens twice, once in EDT (UTC-4) and once in EST (UTC-5). A collector that logs “2026-11-01 01:30” in local time records something that cannot be placed. A collector that logs UTC records either 05:30 or 06:30, and there is no ambiguity. In spring the opposite happens: an hour of local time never exists, and naive schedulers skip or double-run jobs.

What timestamptz does and doesn’t do

PostgreSQL’s timestamp with time zone is the right type for instants, but its name misleads. It does not store a time zone. On input, the value is converted to UTC using the offset or zone you supplied (or the session’s TimeZone if you supplied none). On output, it is converted to the session’s time zone. The original offset is gone. If you need to know that a price was displayed in a page that said “ends 11:59 PM PT”, store that zone in its own column.

SQL
SET TIME ZONE 'UTC';
SELECT '2026-11-01 01:30:00-04'::timestamptz;   -- 2026-11-01 05:30:00+00
SELECT '2026-11-01 01:30:00-05'::timestamptz;   -- 2026-11-01 06:30:00+00

SET TIME ZONE 'America/New_York';
SELECT '2026-11-01 05:30:00+00'::timestamptz;   -- 2026-11-01 01:30:00-04
SELECT '2026-11-01 06:30:00+00'::timestamptz;   -- 2026-11-01 01:30:00-05

You observe states, not changes

A collector sees the price at the moments it looks. If it saw $50 at 14:00 and $45 at 20:00, the change happened somewhere in those six hours, and the data cannot say where. Pipelines routinely write the change time as 20:00 and then report “the competitor cut the price at 8 pm”, which nobody observed.

You observe states, not changes

Four observations of one price, six hours apart; the change time is only known to a window

06:0008:0010:0012:0014:0016:0018:0020:0022:0000:0002:0004:00change happened somewhere in here$50$50$45$45Observed: valid_from = first time we saw the price. The true change time is only bounded, never observed.Store both bounds if you need them: last_seen_old = 14:00, first_seen_new = 20:00.
Illustrative example. Graphic: JsonEngine.

Two habits keep this honest. When building a price history, set valid_from to the first observation of the new value and say in your documentation that it is an upper bound on the change time. And when change timing matters, for example in a MAP enforcement case or an analysis of who moved first, keep the last observation of the old value as well, so the uncertainty window is explicit. Collection frequency is what shrinks that window; no amount of modeling does.

Python: make every datetime aware

Python
from datetime import datetime, timezone
from zoneinfo import ZoneInfo

def observed_now():
    return datetime.now(timezone.utc)            # aware, UTC

def parse_local(text, zone):
    """'2026-11-01 01:30' in a named zone -> aware datetime, ambiguity flagged."""
    naive = datetime.fromisoformat(text)
    first = naive.replace(tzinfo=ZoneInfo(zone), fold=0)
    second = naive.replace(tzinfo=ZoneInfo(zone), fold=1)
    ambiguous = first.utcoffset() != second.utcoffset()
    return first, ambiguous

dt, ambiguous = parse_local("2026-11-01 01:30", "America/New_York")
print(dt.astimezone(timezone.utc), ambiguous)   # 2026-11-01 05:30:00+00:00 True

datetime.utcnow() returns a naive value and is deprecated as of Python 3.12; use datetime.now(timezone.utc). The fold attribute, from PEP 495, is how Python distinguishes the first and second occurrence of a repeated local time.

A checklist for every scraped record

  • observed_at in UTC, from a clock synchronized with NTP.
  • The collection run ID, so rows from one run can be compared with each other.
  • The market’s IANA time zone name (America/Chicago, not “CST”).
  • Any dates the page states, verbatim, plus the zone you interpreted them in.
  • Last-Modified or lastmod if the site provides them, treated as claims, not facts.
  • For histories: half-open [valid_from, valid_to) intervals, and the last-seen time of the previous value when change timing matters.

The same discipline applies to the schemas in our competitor price monitoring guide: a “freshness” metric is only as good as the timestamps behind it.

Quick answers

Should I store scraped timestamps in UTC?

Yes, for instants such as when a page was fetched. Store the market’s time zone and any local dates shown on the page in separate fields so you can interpret them later.

Does PostgreSQL timestamptz store the time zone?

No. It converts the input to UTC and stores the instant. On output it converts to the session’s TimeZone setting. If you need the original zone, store it in another column.

Why are some local times ambiguous?

When daylight saving time ends, clocks go back and an hour of local time occurs twice. In New York on 1 November 2026, 01:30 occurs once in EDT and once in EST.

When did a scraped price actually change?

Somewhere between the last observation of the old price and the first observation of the new one. The exact time is not observed; more frequent collection narrows the window.

Price histories you can date

Every record we deliver carries a UTC observation time, the run it came from and the market context it was collected in. See price monitoring.