Menu

Store Timestamps in UTC, Display Them Locally
📰

Store Timestamps in UTC, Display Them Locally

DEV Community: beginners·chirag·1 day ago
#YAxkPpXv
#devtobeginners#devto#dev#timezone#time
Reading 0:00
15s threshold

A CRM stores '10:30' beside a follow-up task. One representative reads it in Jaipur and another in London. Neither knows which timezone the value represents.

Time data needs to describe either an instant or a local scheduling intention. Those are different requirements.

Store instants unambiguously

An enquiry acceptance time is an instant. Store it using a timezone-aware database type or an explicit UTC representation supported by your system.

JavaScript can serialize a valid Date as a UTC ISO string:

const acceptedAt = new Date (); const timestamp = acceptedAt . toISOString ();

Enter fullscreen mode

Exit fullscreen mode

This records the browser or server clock's value. For authoritative acceptance time, prefer the backend's timestamp and maintain its clock synchronization.

Do not infer an instant from an ambiguous string such as 06/07/2026 10:30.

Format for the reader

Display an instant in an explicit timezone using a locale-aware formatter:

const display = new Intl .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.