4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JavascriptでブラウザからAsia/Tokyoのようなタイムゾーン名を取得する方法

Posted at

以下のような感じに取得できる。

const tz = Intl.DateTimeFormat().resolvedOptions().timeZone
console.log(tz) // 東京のブラウザで実行するとAsia/Tokyoが表示される

Intlからは、タイムゾーンだけでなく、言語など、国際化に関連したAPIを他にも利用できるらしい。

参考
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Intl
https://stackoverflow.com/questions/6939685/get-client-time-zone-from-browser

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?