求一个时间统计的代码!需要日小时分秒

来源:百度知道 编辑:UC知道 时间:2024/05/29 08:14:52
[quote]
<font color="#FF0000">今天是我们相爱的第<font color="#0000FF">
<script language=javascript>
var urodz= new Date("03/04/2005");//括号里修改为你的日期(月/日/年)
var now = new Date();
var ile = now.getTime() - urodz.getTime();
var dni = Math.floor(ile / (1000 * 60 * 60 * 24));
document.write(+dni)
</script></font> 天</font>
[/quote]

这个是我目前用的天统计。 如何实现小时分秒。。。。

<font color="#FF0000"><span id="timeDate">载入天数...</span><span id="times">载入时分秒...</span></font>
<script language=javascript>
var now = new Date();
function createtime(){

var grt= new Date("8/08/2004 20:00:00");

now.setTime(now.getTime()+250);
days = (now - grt ) / 1000 / 60 / 60 / 24;
dnum = Math.floor(days);
hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum);
hnum = Math.floor(hours);
if(String(hnum).length ==1 ){hnum = "0" + hnum;}
minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);
mnum = Math.floor(minutes);
if(String(mnum).length ==1 ){mnum = "0" + mnum;}
seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
snum = Math.round(seconds);
if(String(snum).length ==1 ){snum = "0" + snum;}

document.getElementById(&quo