react-native 判断传入的日期是否是昨天

const isYesterday=(theDate='2022-1-1 10:12:00')=>{
    theDate = new Date(theDate)
    var date = (new Date());    //当前时间
    var today = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime(); //今天凌晨
    var yestday = new Date(today - 24*3600*1000).getTime();
    if(theDate.getTime() < today && yestday <= theDate.getTime()){
      return true
    }else{
      return false
    }
    // console.log(theDate.getTime() < today && yestday <= theDate.getTime(), '------')
  }

 

posted @ 2022-09-25 13:50  龙卷风吹毁停车场  阅读(43)  评论(0)    收藏  举报