chrome和firefox中的getTime不同结果 [英] getTime in chrome and firefox different result
问题描述
我需要将 Date
对象转换为 timestamp
,因此创建新的 Date
对象从日期时间开始,并使用 getTime
,但在Chrome和Firefox中会产生不同的结果。具体取决于时区。
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对时区的关注,但chrome不要不在乎。在这种情况下,我该如何强迫Firefox像chrome一样工作?为什么它们的行为有所不同?
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?
我在寻找与跟随psudo不同的方式代码:
I'm searching for the way difference than following psudo code:
if (Firefox){
// plus with 270*60*1000
}
-
从MySQL返回的日期时间,然后替换 space
由 T
在javascript中实现。
--
datetime returned from MySQL,then replace space
by T
in javascript.
推荐答案
在此处工作演示
尝试使用标准日期/时间格式:
Working Demo Here
try using the standard date/time format:
var date = new Date("mm dd, yy hh:mm:ss");
在 JSFiddle
这篇关于chrome和firefox中的getTime不同结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!