Hvis du selv vil bruge mindre kode, kan du bruge mit Date-udvidelses-bibliotek:
http://roenving.users.whitehat.dk/date/roenvingDate.html-- f.eks. sådan:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd"><html>
<head>
<title>Tilføj dage til dato</title>
<meta name="keywords" content="søgeord adskilt af komma">
<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;}
</style>
<script language="javascript" type="text/javascript">
function tilfoej(dato,dage){
if(!dato.match(/^\d{4}-\d{2}-\d{2}$/)){
alert("Fejl i indtastet dato-format");
return;
}
dato = dato.split("-");
var d = new Date(dato[0],(+dato[1]-1),dato[2]);
d = d.dateDiff('set',0,0,+dage);
document.getElementById("nyDato").innerHTML = d.format("yyyy-mm-dd");
}
</script>
<script language="javascript" type="text/javascript" src="roenvingDate.js"></script>
</head>
<body>
<br>
<form id="minForm" name="minForm">
Dato: <input id="dato" name="dato" type="text" value="YYYY-MM-DD" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" size="20"><br>
Tilføj dage: <input id="tilDage" name="tilDage" autocomplete='off' type="text" value="0" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;" size="20">
<button name="Tilfoej" id="Tilfoej" onclick="tilfoej(this.form.dato.value,this.form.tilDage.value);">Tilfoej dage</button>
</form>
<br>
<br>
Ny Dato: <span id="nyDato">YYYY-MM-DD</span>
</body>
</html>