Så får jeg en change for at udnytte mine Date-udvidelser:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<title>Vis alder</title>
<meta name="keywords" content="roenving,
http://www.eksperten.dk/spm/520879"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
html,body{height:100%;margin:0px;border:0px;padding:0px;font-family:tahoma,verdana,arial,sans-serif;font-size:small;}
#minDiv{text-align:center;padding:3px;color:red;font-weight:bold;}
#minSpan{color:green;font-weight:normal;}
</style>
<script language="javascript" type="text/javascript">
Date.prototype.age = function(d,ignoreTime){
if(this.age.arguments.length==0)d = new Date(0);
if(typeof d != 'object' || !d.getTime){
return argsFailure(typeof d);
}
ignoreTime = (this.age.arguments.length==1||!this.age.arguments[1])?false:true;
var c = [1000,60,60,24];
var t = new Array();
t[t.length] = this.getMilliseconds() - d.getMilliseconds();
t[t.length] = this.getSeconds() - d.getSeconds();
t[t.length] = this.getMinutes() - d.getMinutes();
t[t.length] = this.getHours() - d.getHours();
t[t.length] = this.getDate() - d.getDate();
t[t.length] = this.getMonth() - d.getMonth();
t[t.length] = this.getFullYear() - d.getFullYear();
for(i=0;4>i;i++){
if(ignoreTime){
t[i] = 0;
}else if(0>t[i]){
t[i] += c[i];
t[i+1]--;
}
}
if(0>t[4]){
t[4] += new Date(this.getFullYear(),this.getMonth(),0).getDate();
t[5]--;
}
if(0>t[5]){
t[5] += 12;
t[6]--;
}
return [t[6],t[5],t[4],t[3],t[2],t[1],t[0]];
}
var dato = new Date(2002,10,22,21,17,00);
function setTid(){
var alder = new Date().age(dato);
var txt = alder[0] + " år<br>" + alder[1] + " måneder<br>" + alder[2] + " dage<br>" + alder[3] + " timer<br>" + alder[4] + " minutter<br>" + alder[5] + " sekunder";
document.getElementById('minSpan').innerHTML = txt;
}
</script>
</head>
<body onresize onload="setTid();setInterval('setTid()',1000);">
<br>
<div id="minDiv">Vores datter er nu:<br>
<span id="minSpan">En span-tekst</span></div>
</body>
</html>