我想将 Date 对象(日期为 MM/DD/YYYY 格式的“12/01/2019”)作为 JSON 字符串传递给 API。但是,当将此日期(不考虑时区)转换为 JSON 字符串时,日期会更改为前一天。请参阅下面给出的代码:
var newDate = new Date("12/01/19");
console.log(newDate) // Showing Sun Dec 01 2019 00:00:00 GMT+0530 (India Standard Time)
var jsonDate = JSON.stringify(newDate);
console.log(jsonDate) // Showing "2019-11-30T18:30:00.000Z"
Run Code Online (Sandbox Code Playgroud)
日期 2019 年 12 月 1 日更改为 2019 年 11 月 30 日。就我而言,我无法考虑时间或时区。我也无法使用“Moment JS”。
为什么会出现这种情况?谁能具体说明这个奇怪问题背后的原因吗?