<!-- 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>
标签:02,tmpEndTime,tmpBeginTime,时间差,60,var,alert,字符串,JS
From: https://blog.51cto.com/u_16179085/6663461