-1

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 ?

David R
  • 14,711
  • 7
  • 54
  • 72
Azmath Ikram
  • 25
  • 1
  • 6

2 Answers2

0
var d = new Date();
var n = d.getUTCDate(); 
anshuVersatile
  • 2,030
  • 1
  • 11
  • 18
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