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
timestamptzstores 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:
| Field | Meaning | Source | Store as |
|---|---|---|---|
observed_at | When the response was received | Your collector’s clock, synchronized | UTC instant |
valid_from, valid_to | The interval during which your history says the value held | Derived from observations | UTC instants, half-open interval |
loaded_at | When the row reached the warehouse | Your pipeline | UTC instant |
source_modified | When the site says the content changed (Last-Modified, sitemap lastmod) | The site, if it says | UTC instant, nullable |
promo_start, promo_end | Dates the page states for a sale | Page text | Local 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
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.
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
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
Pythonfrom 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_atin 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-Modifiedorlastmodif 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.
