var offset = new Date().getTimezoneOffset(); console.log(offset);
The time-zone offset is the difference, in minutes, between UTC and local time.
(时区偏移量是UTC与本地时间之间的差(以分钟为单位)。)
Note that this means that the offset is positive if the local timezone is behind UTC and negative if it is ahead.(请注意,这意味着如果本地时区在UTC之后,则偏移量为正;如果在本地时区之前,则偏移量为负。)
For example, if your time zone is UTC+10 (Australian Eastern Standard Time), -600 will be returned.(例如,如果您的时区是UTC + 10(澳大利亚东部标准时间),则将返回-600。)
Daylight savings time prevents this value from being a constant even for a given locale(夏时制即使在给定的语言环境下也可以防止该值保持恒定)
Note that not all timezones are offset by whole hours: for example, Newfoundland is UTC minus 3h 30m (leaving Daylight Saving Time out of the equation).
(请注意,并非所有时区都被整个小时抵消:例如,纽芬兰是UTC减去3h 30m(将夏令时排除在外)。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…