天天看点

数组对象里面对日期进行排序

var  hislist =  [{ 'id':'1','date','2020-11-21  15:16:09'},
                     { 'id':'2','date','2020-11-22  10:11:06'},
                     { 'id':'3','date','2020-11-24  15:32:06'},
                      { 'id':'4','date','2020-11-25  18:41:46'}];      
let Onecycledate: any = hislist;
    let twocycledate = Onecycledate.hisList;

    let way: any = Array.from(new Set(twocycledate));
    let rows = way.rows;
    way = rows.sort(function (a, b) {
      return Date.parse(a.createDate) - Date.parse(b.createDate)
    });
    let createDate = way[0].createDate;