How can I convert a string to a date in JavaScript?(如何在JavaScript中将字符串转换为日期?)
var st = "date in some format" var dt = new date(); var dt_st= //st in date format same as dt
The best string format for string parsing is the date ISO format together with the JavaScript Date object constructor.(字符串解析的最佳字符串格式是日期ISO格式以及JavaScript Date对象构造函数。)
YYYY-MM-DD
YYYY-MM-DDTHH:MM:SS
new Date('2011-04-11T10:20:30Z')
.toUTCString()
.toString()
new Date('2011', '04' - 1, '11', '11', '51', '00')
1.4m articles
1.4m replys
5 comments
57.0k users