Date-Only Values vs. Timestamps
A date-only value names a calendar day. A timestamp identifies an instant. Converting between them requires a time and time-zone decision.
Two different questions
A birthday such as 4 May is usually observed as a calendar date. It does not describe one instant shared by everyone on Earth. A transaction at a particular second, on the other hand, happened at a specific moment that can be shown differently in different regions.
These are different data types, even when both are displayed in a calendar. A date-only value answers “which day?” An instant answers “when on the shared timeline?” A local appointment combines a date and clock time with the zone rules needed to resolve it to an instant.
The midnight UTC trap
Suppose an application represents the date 2026-05-04 as midnight UTC. In a region behind UTC, that instant can be displayed on 3 May. The conversion has not changed the instant, but it has changed the visible date, which can be wrong for a birthday or all-day holiday.
The safer model is to preserve the date components as a date-only value until an instant is genuinely needed. If a business process requires a cutoff time, explicitly define the time, the named zone and how ambiguous or missing local times are resolved.
Deadlines and all-day events
A deadline described only as “4 May” may depend on a jurisdiction, organization or contract. It might mean the end of the local calendar day, an office closing time, or another specified cutoff. Do not invent a universal midnight convention for legal or financial use.
All-day calendar events also need clear start and end conventions. Software often uses an inclusive start date and an exclusive end date to represent a range of whole days. See inclusive date ranges for why endpoints matter.
APIs and databases
Use a date field or an unambiguous date string when the intended value is only a date. Use a timestamp or date-time with an explicit offset when an exact instant is required. For a future local event, include the zone identifier and original local intent as well.
Programming libraries may interpret date-only strings differently from date-time strings without an offset. Check the platform's parsing rules and test in both positive and negative UTC offsets. The JavaScript date guide explains one important example.
A selection checklist
Ask whether two people in different zones should see the same calendar date or the same instant. Ask whether a clock time and a zone are part of the original request. If the value repeats, record the recurrence rule separately. These questions usually reveal the right representation.
Explore calendar dates, Unix timestamps and database date storage for related decisions.
Seeing the shift in JavaScript
JavaScript gives a concrete example of the trap. The ECMAScript rules treat a date-only ISO string as UTC, but a date-time string without an offset as local time:
new Date("2026-05-04") // 2026-05-04T00:00:00Z (UTC midnight)
new Date("2026-05-04T00:00") // local midnight in the browser's zone
On a computer in New York (UTC−4 in May), the first value prints as 3 May with toLocaleDateString(). Nothing was corrupted. A date was turned into an instant, and the instant was shown in a zone behind UTC.
Choosing the type, case by case
- A birthday or public holiday is a date. Store
2026-05-04and nothing else. - A flight departure is a local date and time in a named zone, for example
2026-05-04 09:15inEurope/Paris. The instant can be derived from that. - A card payment that was captured is an instant. Store a UTC timestamp.
- An office deadline is a date plus a local cut-off time and a zone. All three belong in the record or in the rule that produces it.
Three habits cause most of the bugs: saving a date as midnight in the server's zone, sorting dates written as DD/MM/YYYY as text, and exporting date columns to CSV with a time part attached. Each of them adds an assumption the original value never had.
Common questions
Can I store a birthday as noon UTC to avoid the shift?
It is a common workaround and it keeps the same calendar date for offsets from UTC−12 to UTC+11. It still fails for zones such as UTC+13 and UTC+14, where noon UTC is already the next day. A real date type avoids the guesswork.
How should all-day calendar events be stored?
As dates. iCalendar marks them with VALUE=DATE, so every attendee sees the event on the same calendar day wherever they are.