Question

Independent of where my server/OS is....

  1. How can I specify 5am "Australia/Sydney" and view this in GMT?
  2. How can I specify 5pm "America/New_York" and view this in GMT?

How can I find the difference between 1) and 2) in minutes. For example, I expect this difference to vary throughout the year as daylight saving in either Sydney or New_York becomes (in)active.

Était-ce utile?

La solution

Here is the solution:

var startDay = moment.utc("2013-06-02"); // Sunday (day before) in GMT
var startOffset = moment.utc(startDay).add("hours", 15).tz("Australia/Sydney").zone();// 15:00pm == -660 // 16:00pm == -600 // IN GMT
var startUTC = moment.utc(startDay).add('minutes', 1740).add("minutes", startOffset);

var endDay = moment(startDay).add('days' ,5); //moment.utc("2014-03-10"); // Friday in GMT
var endOffset = moment.utc(endDay).add("hours", 7).tz("America/New_York").zone(); 
var endUTC = moment.utc(endDay).add('minutes', 1020).add("minutes", endOffset);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top