比较两个日期不能超过几个月

// mons 月数 stTime开始时间 endTime结束时间 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个月 console.log('末位时间小于6个月')     return true; }   return false; } compareTime(6,'2022-07-01','2022-12-31')
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章