Skip to content

Dates and Timezones

Paulius Juzenas edited this page Oct 12, 2026 · 1 revision

Dates and Timezones

The server always runs in UTC. No timezone is set in the containers. So the server should never ask what day, month or hour a date falls on. It should only compare instants with Date, Date.now() and .getTime().

Displaying a date to a user is different. For that you need a timezone, and it should always be Europe/Oslo. Almost everything we show, like event times and deadlines, should look the same to every user. It should not change based on the visitor's own device.

There is one exception. Native HTML date and datetime-local inputs are always local to the browser. That is fine and already handled by DateInput and displayDefaultInputValue.ts.

Rules

  • Never write new Date(year, month, day, ...). It reads the fields using the local timezone of whatever machine runs the code. Use an ISO string, Date.UTC(...), or plain instant math like Date.now() + ms instead.
  • Never call date.getDate(), .getMonth(), .getFullYear(), .getHours(), .getMinutes(), .getSeconds() or .getDay() inside src/services or src/lib. Use the getUTC versions instead. If you need the date in Oslo time for display, use osloDateTime(date) from @/lib/dates/oslo.
  • Never call .toLocaleString(), .toLocaleDateString() or .toLocaleTimeString() without a timeZone option. Use displayDate(date) from @/lib/dates/displayDate, or pass timeZone: 'Europe/Oslo' yourself.

All three rules are enforced by eslint and will fail the build if broken.

Clone this wiki locally