【问题标题】:Kendo grid datetime convert issue in IEIE中的剑道网格日期时间转换问题
【发布时间】:2016-12-21 09:49:37
【问题描述】:

大家好~我正在使用 Kendo 网格从服务器端 Web API 显示日期时间列。

在Chrome中,结果按预期显示。但是在IE中,我遇到了一些问题:

在响应正文中,我得到了数据:

[{"SerialNO":43,"SurveyCyclesSN":null,"StartDateTime":"2016-12-21T00:00:00","EndDateTime":"2016-12-30T11:00:00"}]

在 Chrome 中,剑道网格将 UTC 时间正确地转换为本地时间: the correct value

但在 IE 中,日期时间不能正确转换: the wrong value

对这个问题有什么建议吗?谢谢~

【问题讨论】:

  • 您希望输出哪种格式?
  • 嗨~我用这段代码做格式:
  • kendo.toString(kendo.parseDate(StartDateTime), 'yyyy/MM/dd')

标签: kendo-grid


【解决方案1】:

你可以试试这个:

 new Date(kendo.toString("Fri Dec 30 2016 19:00:00 GMT+0800")) or

 new Date("Fri Dec 30 2016 19:00:00 GMT+0800") 

它给了我=>

2016 年 12 月 30 日星期五 16:30:00 GMT+0530(印度标准时间)

这是代码

 new Date(kendo.toString(StartDateTime))

附加图片:

您的数据是这样的: 见红点。

您应该使用更好的格式化程序,例如 Newtonsoft json 转换器。

【讨论】:

  • 感谢您的回答。我想澄清这个问题,我写了一些控制台来记录日期时间值:
  • { title: "&nbsp", template: function (e) { console.log('StartDateTime: ', e.StartDateTime); console.log('kendo.parseDate:', kendo.parseDate(e.StartDateTime)); console.log('kendo.toString:',new Date(kendo.toString(e.StartDateTime,'yyyy/MM/dd')));}
  • 在 Chrome 中,StartDateTime 为 => 2016 年 12 月 21 日星期三 08:00:00 GMT+0800(台北标准时间);在 IE 中是 => Wed Dec 21 2016 00:00:00 GMT+0800(台北标准时间),因此时区似乎转换正确,但小时部分有问题。我该如何解决这个问题?
  • 我可以通过运行看到相同的答案:console.log('kendo.parseDate:', kendo.parseDate("Fri Dec 30 2016 19:00:00 GMT+0800")或 console.log('kendo.parseDate: ', kendo.parseDate("2016-12-30T11:00:00")) 更新浏览器,我使用的是 IE 11
  • 我也在用IE 11,所以不知道是什么原因。还是谢谢~
猜你喜欢
  • 1970-01-01
  • 2013-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-11
  • 1970-01-01
  • 2020-11-05
  • 2016-10-22
相关资源
最近更新 更多