javascript比较时间

Posted on 2009-08-03 16:42  名号M  阅读(153)  评论(0编辑  收藏  举报
转载http://zmfkplj.javaeye.com/blog/401978
//日期比较
 function compareDate(dateOne,dateTwo){
  var s1 = dateOne.replace(/-/g, "/");
  var s2 = dateTwo.replace(/-/g, "/");
  
  s1 = new Date(s1);
  s2 = new Date(s2);
  
  var days= s1.getTime() - s2.getTime();
  var time = parseInt(days / (1000 * 60 * 60 * 24));
  
  //alert("相差天数: " + days);
  
  return days>0;
 }

Copyright © 2024 名号M
Powered by .NET 8.0 on Kubernetes