<html>
<head>
<title>Date substraction</title>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
var myVar =
prompt("Please enter a date: ")
var udate =
Date.parse(myVar);
var todate
= new Date();
var
diffdate = user_date - today_date;
var years =
diffdate / 31536000000;
var months
= (diffdate % 31536000000) / 2628000000;
var days =
((diffdate % 31536000000) % 2628000000) / 86400000;
document.write("Number
of years: " + Math.floor(years) + "<br>");
document.write("Number
of months: " + Math.floor(months) + "<br>");
document.write("Number
of days: " + Math.floor(days) + "<br>");
//-->
</script>
</body>
</html>
No comments:
Post a Comment