#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    42
    Rep Power
    2

    Count 1 minute in php


    Hi,

    Everything is working fine except the start time. Once I click start, i want to see start time is ticking but start time does not change. I want future time static and start time dynamic.

    Please advise.
    PHP Code:
    <html>

    <?PHP
    $From 
    date("H:i:s");
    echo 
    "From  $From ";
    $Minutes 1;
    echo 
    "<br />";
    $To date("H:i:s"strtotime($From)+($Minutes*60));
    ?>

    <SCRIPT language="JavaScript">

    function newtext()
    {
    document.getElementById("stBtn").disabled = true;
    starttime = '<?php echo $From ;?>';
    futuretime = '<?php echo $To ;?>';

    document.getElementById("start").innerHTML = starttime;
    document.getElementById("future").innerHTML = futuretime;
    setTimeout("moretext()",1 * 60000);
     }

    function moretext()
    {

    document.getElementById("subBtn").disabled = true;
    }

    </SCRIPT>

    </HEAD>

    <BODY>

    <FORM name="myform" method="post" action="sessionS1.php">

    <table width='600' cellpadding='5' cellspacing='5' border='1'> 
    <tr> <td> <p id="start"></p> </td> <td> <p id="future"></p>  </td> <td> </td> </tr>

    <tr><td colspan=6 align='right'><INPUT class = "button" id="stBtn" TYPE="button" name= mytext value="StartExam" onClick="newtext

    ()"></td></tr> 

    <tr><td colspan=6 align='right'><input type='submit' id="subBtn"value='Score' name='btn_score'></td></tr> 

    </table> 

    </FORM>

    </body>
    </html>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,497
    Rep Power
    594
    This is a JavaScript question. For a Javascript example of a countdown timer see this.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Posts
    4
    Rep Power
    0
    As already mentioned, this is really a javascript question. However, you seem to be getting the starting time from PHP? Why? You may want to search google because many people have had the same reuest as yourself and will have created a solution.

IMN logo majestic logo threadwatch logo seochat tools logo