I am coding a MVC 5 internet application, and would like to know how to perform a calculation in a view every second.
Here is my view code:
var expires = Model.account.subscriptionEndDate - DateTime.UtcNow;
How can I calculate the expires value every second so that I can display this value? The Model.account.subscriptionEndDate
is a DateTime
in UTC
.
Thanks in advance.
javascript:
var myVar=setInterval(function () {myTimer()}, 1000);
function myTimer() {
var d = new Date();
document.getElementById("demo").innerHTML = d.toLocaleTimeString();
}