0

Through an API I would like to expose the timezone of a server. What's the best way of exposing this information? UTC offset only (e.g. +02:00) or shall I use any abbreviation? I'm following the ISO 8601 standard.

Dunken
  • 7,909
  • 4
  • 51
  • 76

1 Answers1

1

Neither are the correct choice. Abbreviations can be ambiguous, and a time zone and a time zone offset are two different things. A time zone in an API should generally be represented by its IANA TZ Database identifier, such as America/Los_Angeles, Europe/London, or Asia/Tokyo.

You'll find more information about time zones, abbreviations, and "time zone != offset" in the timezone tag wiki.

Do consider also that it's a general best practice to always set a server's time zone to UTC, and to never expect a server to be on any time zone in particular. Your desire to expose an API for the server's time zone would seem to go against both. Make sure you have a very good reason before you lock yourself into this design.

Community
  • 1
  • 1
Matt Johnson-Pint
  • 197,368
  • 66
  • 382
  • 508