两个日期之间相差的天数

/***************两个日期之间相差的天数***********************
<脚本 type="text/java脚本">
function compute()
{


var da = "2008-2-24 9:55:22"
var da1 = "2008-2-29 7:55:22"var arr=da.split(" ");
var arr1=arr[0].split("-");
var arr2=arr[1].split(":");
var date=new Date(arr1[0],arr1[1],arr1[2],arr2[0],arr2[1],arr2[2]);
var arr=da1.split(" ");
var arr1=arr[0].split("-");
var arr2=arr[1].split(":");
var date2=new Date(arr1[0],arr1[1],arr1[2],arr2[0],arr2[1],arr2[2]);

var startDate= new Date(date);
var endDate= new Date(date2);
var df=(endDate.getTime()-startDate.getTime())/(24*60*60*1000);
alert( parseInt(df)+"天" );


}

/*********javascrpt 现在时间*******************/
<脚本>
function show()
{
now=new Date();
year=now.getYear();
month=now.getMonth()+1;
date=now.getDate();
hours=now.getHours();
minutes=now.getMinutes();
seconds=now.getSeconds();
if(minutes<=9)
minutes="0"+minutes
if(seconds<=9)
seconds="0"+seconds
time.innerHTML=year+"年"+month+"月"+date+"日"+"现在时间:"+hours+":"+minutes+":"+seconds;
setTimeout("show()",1000);
}
show();

你可能感兴趣的:(日期)