LoginSignup
2
1

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

2
1
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
2
1