日期:2014-05-16 浏览次数:20305 次
<!-- JS 处理字符串的时间差? 及 比较时间的大小 -->
<html>
?<head>
<script>
(function(){cc();})();
function cc(){
???????? var time1 = "2012-02-20"
???????? var time2 = "2015-02-14"
??????? var tmpBeginTime = new Date(time1.replace(/-/g, "\/")); //时间转换
??????? var tmpEndTime = new Date(time2.replace(/-/g, "\/")); //时间转换
??????? var sumMinTime = 1000 * 60 * 60 * 24 * (365 / 2);
??????? alert((tmpEndTime - tmpBeginTime) / (1000 * 60 * 60 * 24));
??????? if ((tmpEndTime - tmpBeginTime) >= sumMinTime) {
??????????? alert("大于");
??????? } else {
??????????? alert("小于");
??????? }
}
</script>
?</head>
?<body>
?
?</body>
</html>