首页 > 编程语言 > 详细

对后端返回的时间进行升序的排序

时间:2018-09-19 18:48:34      阅读:301      评论:0      收藏:0      [点我收藏+]
other.sort(function(a,b){
let startTime=a.time.replace(/\-/g, ‘/‘)
let endstTime=b.time.replace(/\-/g, ‘/‘)

return Date.parse(startTime) - Date.parse(endstTime);//时间正序
})





时间格式:[
{‘time‘:‘2018-9-10 0-0-0‘,‘first‘:‘page‘},
{‘time‘:‘2018-9-10 0-0-0‘,‘first‘:‘page‘},
{‘time‘:‘2018-9-10 0-0-0‘,‘first‘:‘page‘},
{‘time‘:‘2018-9-10 0-0-0‘,‘first‘:‘page‘}




]

对后端返回的时间进行升序的排序

原文:https://www.cnblogs.com/zhouyideboke/p/9675971.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!