if(timeList && timeList.length > 1) {
timeList.sort((a, b) => { //timeList为字符串(格式如:2022-09-24 16:52:40)
let a1 = Date.parse(a) //转换成时间戳
let b1 = Date.parse(b)
return a1 - b1
})
}
if(timeList && timeList.length > 1) {
timeList.sort((a, b) => { //timeList为字符串(格式如:2022-09-24 16:52:40)
let a1 = Date.parse(a) //转换成时间戳
let b1 = Date.parse(b)
return a1 - b1
})
}
本文标题:JS时间排序
本文链接:https://www.haomeiwen.com/subject/kcbfartx.html
网友评论