javascript new Date with string param has wrong date
本问题已经有最佳答案,请猛点这里访问。
我正在从字符串创建新日期
1 2 3 | var s ="2017-12-06" var dt = new Date(s) console.log(dt) // outputs Tue Dec 05 2017 19:00:00 GMT-0500 (EST) |
我错过了什么?
来自
The date time string may be in a simplified ISO 8601 format. For example,"2011-10-10" (just date) or"2011-10-10T14:48:00" (date and time) can be passed and parsed. Where the string is ISO 8601 date only, the UTC time zone is used to interpret arguments. If the string is date and time in ISO 8601 format, it will be treated as local.
号
所以你最终会得到一个与2017-12-06t00:00:00z相当的