Search code examples
javascriptjquerydateutc

Firefox Defining Date Wrong with new Date().getTime();


I'm defining a variable, data.EndTimeUTC which has a value of "2015-10-09T18:15:00"

Using Javascript, I'm converting that to milliseconds using...

var liveTime = new Date(data.EndTimeUTC).getTime();

In all browsers, it's giving the right answer; 1444414500000 but for whatever reason, Firefox is giving 1444425300000 which is exactly 3 hours off.

Any ideas what's going on there? I'm at a loss.


Solution

  • Try using:

    var liveTime = Date.UTC(2015, 9, 9, 18, 15, 0)

    For your case:

    var fixedUTC = data.EndTimeUTC + "Z";
    
    var liveTime = Date.parse(fixedUTC);