I want to have a continuous daily countdown where the plan will have 2 schedule/specific time daily.
I am now still troubleshoot at 1 specific time.
The following is modification from this answer https://stackoverflow.com/a/23512971/20903104
<script type="text/javascript">
function executeAction (target){
console.log(target);
//next schedule
};
var date;
var remaining = document.getElementById("remaining");
var schedule1 = document.getElementById("schedule1").value.split(":");
var target = schedule1[0];
setInterval(function () {
date = new Date();
var currenthours = date.getHours();
var hours;
var minutes;
var secondes;
if (currenthours != target) {
if (currenthours < target) hours = target - 1 - currenthours;
else hours = target + (24 - currenthours);
minutes = 60 - date.getMinutes();
secondes = 60 - date.getSeconds();
remaining.innerHTML = hours + ":" + minutes + ":" + secondes;
} else {
remaining.innerHTML = "LIVE NOW";
executeAction(target);
//continue to next schedule
};
}, 1000);
</script>
Let say, now is 11:00 (AM) the next schedule is 10:00 (AM) the output is: enter image description here it should be 23:00:00 and counting down
I want to add second (or third schedule) and add this code :
<input type="time" id="schedule1" value="10:00:00" readonly />
<div id="remaining"></div>
<input type="time" id="schedule2" value="22:00:00" readonly />
<div id="remaining2"></div>
How to proceed to next schedule continuously? complete code : https://jsfiddle.net/kuraba/6or71L90/14/