您的位置:首页 > Web前端 > JavaScript

js中计算时间差值 (天数)

2009-05-31 10:26 555 查看
引:http://blog.csdn.net/joinwage/archive/2005/06/10/391395.aspx

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: