Thursday, 15 September 2016
New Year Time Calculation In Days|Hours|Minutes|Seconds Using jQuery and JavaScript
Here I will explain about how to calculate time in days,hours,minutes and seconds for a New Year using jQuery and JavaScript coding. To execute below coding add jQuery script file at the header tag or below of your Html code.
Html Code:
<input id="time">
jQuery Code:
$(function(){
var calculate = setInterval(function(){
date_futureyear = new Date(new Date().getFullYear() +1, 0, 1);
date_currentdatetime = new Date(); //To get current datetime
seconds = Math.floor((date_futureyear - (date_currentdatetime ))/1000);
minutes = Math.floor(seconds/60);
hours = Math.floor(minutes/60);
days = Math.floor(hours/24);
hours = hours-(days*24);
minutes = minutes-(days*24*60)-(hours*60);
seconds = seconds-(days*24*60*60)-(hours*60*60)-(minutes*60);
$("#time").text("Time until new year:\nDays: " + days + " Hours: " + hours + " Minutes: " + minutes + " Seconds: " + seconds);
},1000);
});
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment