I have the var date = new Date()
by this date I want to get EST or UTC date.
Problem is how to determine either it is be EST or UTC ?
Asked
Active
Viewed 170 times
-1

David R
- 14,711
- 7
- 54
- 72

Azmath Ikram
- 25
- 1
- 6
-
whether ....... – Mahi Oct 27 '16 at 11:40
-
2Possible duplicate of [Getting the client's timezone in JavaScript](http://stackoverflow.com/questions/1091372/getting-the-clients-timezone-in-javascript) – wscourge Oct 27 '16 at 11:43
-
Try `(new Date).toString().split('(')[1].slice(0, -1)` – WannaBeCoder Oct 27 '16 at 11:52
-
Javascript Dates are UTC, however *toString* typically returns a value adjusted for the host timezone. – RobG Oct 28 '16 at 00:15
2 Answers
0
var x = new Date();
var currentTimeZoneOffsetInHours = x.getTimezoneOffset() / 60;
The time-zone offset is the difference, in minutes, between UTC and local time. Note that this means that the offset is positive if the local timezone is behind UTC and negative if it is ahead. For example, if your time zone is UTC+10 (Australian Eastern Standard Time), -600 will be returned. Daylight saving time prevents this value from being a constant even for a given locale.
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset
You may also wish to look at moment.js and moment-timezone for a friendly API for timezones.

Alex KeySmith
- 16,657
- 11
- 74
- 152