1<div id="demo"></div>
2<form method="post" id="username">
3<input type="text" name="usename" placeholder="Enter Username">
4</form>
5
6<?php
7
8if ($_SERVER['REQUEST_METHOD'] == 'POST) {
9echo $_POST['username'];
10}
11
12?>
13
14<script>
15function timeRemaining (id, stoptime) {
16 // Set the date we're counting down to
17 var countDownDate = new Date(stoptime).getTime();
18
19 // Update the count down every 1 second
20 var x = setInterval(function() {
21
22 // Get today's date and time
23 var now = new Date().getTime();
24
25 // Find the distance between now and the count down date
26 var distance = countDownDate - now;
27
28 // Time calculations for days, hours, minutes and seconds
29 var days = Math.floor(distance / (1000 * 60 * 60 * 24));
30 var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
31 var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
32 var seconds = Math.floor((distance % (1000 * 60)) / 1000);
33
34 // Output the result in an element with id="demo"
35 document.getElementById(id).innerHTML = days + "d " + hours + "h "
36 + minutes + "m " + seconds + "s ";
37
38 // If the count down is over, write some text
39 if (distance < 0) {
40 clearInterval(x);
41 $('#username').submit();
42 document.getElementById(id).innerHTML = "Time-up";
43 }
44
45 }, 1000);
46 }
47 timeRemaining('demo', 'Dec 2, 2020 14:21:00');
48
49 </script>