Store your dates in UTC
Should you store dates in UTC in a database? Almost always yes. Here's why thinking global from the start saves you a lot of trouble.
1 min read
Should you store your dates in UTC — Coordinated Universal Time — in a database? My suggestion: yes, always. Or almost, unless you have an excellent reason to do otherwise.
Why UTC
Because UTC is the world standard for time. And the benefits show up quickly:
- your users are spread across several time zones;
- your application expands internationally;
- you migrate your system from one place to another.
The simple rule
Store in UTC, display in the local time zone. A small offset computed at display time, and you avoid a host of subtle problems — the kind that only surface months later, when rolling back is expensive.
Better to think global from the start.