例子,js计算时间差:
<script language=javascript>
getday();
function getday()
{
var oldyear = 2007;
var oldmonth = 7;
var olddate = 5;
var now = new date();
var nowyear = now.getfullyear();
var nowmonth = now.getmonth() + 1;
var nowdate = now.getdate();
var syear = nowyear - oldyear;
var smonth = nowmonth - oldmonth;
var sdate = nowdate - olddate;
var passdate = syear * 365 + smonth * 30 + sdate ;
document.write("已工作了<font color='red'>"+ passdate + "</font>天");
}
</script>