Dear experts
I'm not really used to javascript, and I maybe have a silly problem.
In my script I want to calculate the date of today minus a earlier day and need the numbers of day.
Javascript is calculating in milliseconds, right? I get a number of days but they are really wrong.
Do I have to bring the "today"-day in a specified formatting?
I'm not really used to javascript, and I maybe have a silly problem.
In my script I want to calculate the date of today minus a earlier day and need the numbers of day.
Javascript is calculating in milliseconds, right? I get a number of days but they are really wrong.
Do I have to bring the "today"-day in a specified formatting?
JavaScript:
<html>
<head>
</head>
<body>
<h1> Statistik Nummernverbrauch </h1>
<p> Datum im Format [dd.mm.yyyy] eingeben: </p>
<input type="text" name="letztesDatum" id="LastDate" value="">
<button onclick="Berechnung()">Start</button>
<br/>
<br/>
<script>
function Berechnung() {
var d0 = document.getElementById("LastDate").value;
var d1 = new Date(d0);
var d2 = new Date();
var diff = d2.getTime() - d1.getTime();
var daydiff = (diff / 86400000).toFixed(0);
document.write(" letzte Eingabe war vor <b> " + daydiff + " Tagen </b>" );
}
</script>
</body>
</html>