//mons是比较的月数,如 2019-02-01 14:27:08 - 2019-08-01 14:27:08
function compareTime(mons,stTime,endTime){
    var st  = new Date(stTime);
    var et = new Date(endTime);
    var st6mon=new Date(st);
    st6mon.setMonth(st6mon.getMonth()+mons);
    
    if(et.getTime()>st6mon.getTime()){
      //末位时间超时起始时间6个月
    return true;
}
  return false;
//ps:可以用 if(et >(或<) st6mon),但比较if(et==st6mon)永远返回false,可能==返回的是对象地址引用,所以用getTime() }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-20
  • 2022-12-23
  • 2021-07-23
  • 2022-12-23
  • 2021-09-10
相关资源
相似解决方案