JS 日期比较


Js 日期比较方法

第一种方式

function compareDate(s1,s2){
  return ((new Date(s1.replace(/-/g,"\/")))>(new Date(s2.replace(/-/g,"\/"))));
}

第二种方式

var curTime = new Date();
//把字符串格式转化为日期类
var starttime = new Date(Date.parse(begintime));
var endtime = new Date(Date.pares(endtime));
//进行比较
return (curTime>=starttime && cutTime<=endtime);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM