我试着通过以下方式来设置新的时间:
var d = new Date('2011-04-11T' + dataRecord.StartTime);
// If the dataRecord.StartTime ='05:10:10' then d becomes
// Date {Mon Apr 11 2011 05:10:10 GMT+0530 (India Standard Time)}
var e = new Date('2011-04-11T' + dataRecord.EndTime);
这在Mozilla中工作得很好,但在chrome的情况下,它显示了5.30小时的提前!如何更改代码才能在所有浏览器中运行??
发布于 2014-06-13 21:38:12
像这样的东西能奏效吗?
var d = new Date('2011-04-11T05:10:10');
var utc = new Date(new Date().getTime());
d.setMinutes(utc.getTimezoneOffset() + d.getMinutes() );
console.log(d);
我只是从当前浏览器获取偏移量,并将它们添加到您首先创建的日期中。时区偏移量以分钟为单位...
https://stackoverflow.com/questions/24206171
复制相似问题