【发布时间】:2014-03-12 05:46:13
【问题描述】:
我想在我的模块中使用 JSON 格式获取日期,当我将日期值转换为 json 时,它会更改时区,最终日期会更改为例如
var myDateWithJson=(new Date(2014, 03, 11).toJSON());
alert("Date With Json " +myDateWithJson);
var myDateWithoutJson = new Date(2014,03,11);
alert("Date Without Json " + myDateWithoutJson);
我也经历过covert json without timezone 但是,我认为这不是更好的方法 请指导我更好的方法
【问题讨论】:
-
所有 Date 对象的核心是 UTC 时间值。传递日期的最佳方法是使用时间值或基于 UTC 的 ISO 8601 字符串,这是您从 Date.prototype.toJSON 获得的。
标签: javascript json date datetime