countdown php online

Solutions on MaxInterview for countdown php online by the best coders in the world

showing results for - "countdown php online"
Noah
23 Feb 2016
1<?php
2    session_start();
3    if( empty( $_SESSION['quiz'] ) )$_SESSION['quiz']=date('Y-m-d H:i:s');
4?>
5<html xmlns="http://www.w3.org/1999/xhtml">
6<head runat="server">
7    <title></title>
8    <script language ="javascript" >
9    <?php
10              $start=$_SESSION['quiz'];
11              $end=date('Y-m-d H:i:s', strtotime( $_SESSION['quiz'] . ' +20 minutes' ) );
12                echo "
13                    var date_quiz_start='$start';
14                    var date_quiz_end='$end';
15                    var time_quiz_end=new Date('$end').getTime();";
16      ?>
17        var tim;
18        var hour= 00;
19        var min = 01;
20        var sec = 60;
21        var f = new Date();
22        function f1() {
23            f2();
24            document.getElementById("starttime").innerHTML = "Your started your Exam at " + f.getHours() + ":" + f.getMinutes();
25
26        }
27        function f2() {
28            if (parseInt(sec) > 0) {
29                sec = parseInt(sec) - 1;
30                document.getElementById("showtime").innerHTML = "Your Left Time  is :"+hour+" hours:"+min+" Minutes :" + sec+" Seconds";
31                tim = setTimeout("f2()", 1000);
32            }
33            else {
34                if (parseInt(sec) == 0) {
35                    min = parseInt(min) - 1;
36                    if (parseInt(min) == 0) {
37                        clearTimeout(tim);
38                        location.href ="index.php";
39                    }
40                    else {
41                        sec = 60;
42                        document.getElementById("showtime").innerHTML = "Your Left Time  is :" + min + " Minutes ," + sec + " Seconds";
43                        tim = setTimeout("f2()", 1000);
44                    }
45                }
46
47            }
48        }
49    </script>
50</head>
51<body onload="f1()" >
52    <form id="form1" runat="server">
53    <div>
54      <table width="100%" align="center">
55        <tr>
56          <td colspan="2">
57          </td>
58        </tr>
59        <tr>
60          <td>
61            <div id="starttime"></div><br />
62            <div id="endtime"></div><br />
63            <div id="showtime"></div>
64          </td>
65        </tr>
66        <tr>
67          <td>
68
69              <br />
70
71          </td>
72
73        </tr>
74      </table>
75      <br />
76
77    </div>
78    </form>
79</body>
80</html>