js中计算时间差值 (天数)
<script>
function check_date_diff(){ //检测日期的间隔时间
var checkArray= new Array() ;// 考核时间转化
var checkDate = "2005/06/10";
checkArray = checkDate.split("/");
checkDate = new Date(checkArray[0],checkArray[1],checkArray[2]);
var nowTime = new Date();// 当前时间
var the_year = nowTime.getYear();
var the_month = nowTime.getMonth() + 1;
var the_day = nowTime.getDate();
nowTime = new Date(the_year,the_month,the_day);
var thesecond = 24 * 60 * 60 *1000 ;
var diffTime = (nowTime - checkDate)/thesecond;
//alert("ssc "+diffTime/thesecond);
return diffTime;
}
</script>
该博客介绍了在JavaScript中计算日期时间差值(天数)的方法。通过定义函数,将考核时间和当前时间分别处理为Date对象,再计算两者差值并转换为天数,最后返回计算结果。
5021

被折叠的 条评论
为什么被折叠?



