Hi Friends,

<html>
<head>
<script type="text/javascript">

 <form action="javascript:void(null);" name="theTimer">
        <input type=text name="theTime" size="25" />


        <input type=button name="start" value="Start" onclick="Start()" /> 
 </form><html>
<head>
<title>Timer</title>
<script type="text/javascript" language="JavaScript">
timerID = 0;
tStart  = null;
tDiff = 0;
document.theTimer.theTime.value = "00:00:00";

function UpdateTimer() {
    if(timerID) {
        clearTimeout(timerID);
    }

    if(!tStart) {
        tStart   = new Date();
    }

    var tDate = new Date();
    tDiff = tDate.getTime() - tStart.getTime();

    tDate.setTime(tDiff);

    hours = new String(tDate.getUTCHours());
    if(hours.length == 1) {
        hours = "0"+hours;
    }

    minutes = new String(tDate.getUTCMinutes());
    if(minutes.length == 1) {
        minutes = "0"+minutes;
    }


    seconds = new String(tDate.getUTCSeconds());    
    if(seconds.length == 1) {
        seconds = "0"+seconds;
    }


   document.theTimer.theTime.value = "" + hours + ":" + minutes + ":" + seconds;

   timerID = setTimeout("UpdateTimer()", 1000);

   }

function Start() { 

   timerID  = setTimeout("UpdateTimer()", 1000);

   if(document.theTimer.pause.value=="Start"){
       document.theTimer.pause.value=="Stop";
   }
    else {
    document.theTimer.pause.value = "Pause"; 
        tToday = new Date();
        total_time = tToday.getTime() - tDiff;
        tStart = new Date(total_time);  
        timerID  = setTimeout("UpdateTimer()", 1000);
    } 
}


</body>
</html> 

This code will display the time as 00:00:00.And the clocks ticks.But i need to modify the code as Eg: i need to give the time then the clock shoould from that.
if i am giving the time as 00:05:00 then i clock should start from that.. like that..user input time and the clcik starts from there.How to modify this. Any idea or idea.

Thanks ,
Deepak

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.