Calculate the days between two dates
<html>
<head>
<title>the date</title>
</head>
<body>
<p id="dateField"> </p>
<script type = "text/javascript">
var today = new Date();
var then = new Date();
then.setFullYear(3000,1,1);
var diff = then.getTime() - today.getTime();
diff = Math.floor(diff / (1000 * 60 * 60 * 24));
var dateLoc = document.getElementById("dateField");
dateLoc.innerHTML = diff + " days";
</script>
</body>
</html>
Related examples in the same category