1function Update() {
2 var id = 'demo'; // Display ID for time left 'demo'
3 var countDownDate = new Date('Dec 3, 2020 15:34:00').getTime();
4 var now = new Date().getTime();
5 var distance = countDownDate - now;
6 if (distance > 0) {
7 var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
8 var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
9 var seconds = Math.floor((distance % (1000 * 60)) / 1000);
10
11 if (distance < 0) {
12 document.write("Time-up");
13 } else {
14 document.getElementById(id).innerHTML = (hours + "h " + minutes + "m " + seconds + "s ");
15 }
16 window.setTimeout('Update()', 1000);
17 } else {
18 document.getElementById(id).innerHTML = ("Form is submitting");
19 $('.username').submit(); // Form to submit but add action="actionpage.php"
20 }
21 }
22 Update();