我如何使Javascript的日期正确解释? [关闭]

问题描述 投票:-3回答:2
Javascript的日期应该按月/日/年的顺序,但这是:

new Date('6/6/2020') // Interpreted in the day/month/year order, 6/6/2020 when it should've interpreted in the month/day/year order 6/6/2020

被解释为是按日/月/年顺序?我该如何做才能正确解释它?我已经尝试过

new Date('11/11/2020')

但该错误仍然存​​在    
javascript
2个回答
2
投票
请勿将字符串传递给Date()。如果您要的话,就是在自找麻烦。

0
投票
我不认为Date的构造函数采用这样的参数。这就是医生说的→[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date
© www.soinside.com 2019 - 2024. All rights reserved.