Moein Hosseini
Moein Hosseini

Reputation: 4383

getTime in chrome and firefox different result

I need to convert Date object to timestamp,so create new Date object from datetime and use getTime,but it makes different result in Chrome and Firefox.it depends on timezone.

var date = new Date('2013-08-26T14:30:00');

date.getTime();
//1377527400000 in Chrome
//1377511200000 in Firefox

date.getTimezoneOffset();
//-270 in both of them

Firefox attention to timezone ,but chrome don't care about it.How can I force Firefox to act like chrome in this situation?And Why they act different?

I'm searching for the way difference than following psudo code:

if (Firefox){
    // plus with 270*60*1000
}

-- datetime returned from MySQL,then replace space by T in javascript.

Upvotes: 3

Views: 3742

Answers (2)

Anton
Anton

Reputation: 41

try to use this format:

(new Date('2013-08-26T14:30:00.0Z')).getTime();

and you'l get 1377527400000 for both

Upvotes: 1

ReDEyeS
ReDEyeS

Reputation: 851

Working Demo Here

try using the standard date/time format:

var date = new Date("mm dd, yy hh:mm:ss");

See your code on JSFiddle

Upvotes: 2

Related Questions