现在的位置: 首页 > 综合 > 正文

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

2013年08月26日 ⁄ 综合 ⁄ 共 602字 ⁄ 字号 评论关闭

引: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>

 

抱歉!评论已关闭.