Skip to content

How to implement the textbox showing time in hh:mm:ss

Deepti A

Asked Aug 26, 2007, 10:32 PM EDT1 answer
Share
LinkedInX

Just double-click on the time being shown in ur pc, at right-bottom. Here, below the clock picture, there is an editable textbox cum dropdown control being shown. From this control, the time can be changed... The mouse on "hh" and the "up" arrow will increase the hours, similarly the same happens for minutes and seconds.

I need to implement this control on a web page... can anyone help me?

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    <html>
    <head>
    <script type="text/javascript">
    function startTime()
    {
    var today=new Date()
    var h=today.getHours()
    var m=today.getMinutes()
    var s=today.getSeconds()
    // add a zero in front of numbers<10
    m=checkTime(m)
    s=checkTime(s)
    document.getElementById('txt').value=h+":"+m+":"+s
    t=setTimeout('startTime()',500)
    }

    function checkTime(i)
    {
    if (i<10)
      {i="0" + i}
      return i
    }
    </script>
    </head>

    <body onload="startTime()">
    <input type="text" id="txt">
    </body>
    </html>

    0