<html> <head></head> <body> <div id="show"></div> <input type="button" value='' id='btntime'></input> <script type='text/javascript'> function print(msg) { document.write(msg,'<br/>'); } var changetime = function() { var d=new Date(); var h=d.getHours(); var m=d.getMinutes(); var sec=d.getSeconds(); var ampm=(h>=12)?'PM':'AM'; if(h>12) h-=12; if(h==0)h=12; if(m<10) m='0'+m; var t=h+':'+m+':'+sec+" "+ampm; var button = document.getElementById('btntime'); button.value = "setInterval:"+t; } changetime(); setInterval("changetime()",1000); function time_setTimeOut() { var d=new Date(); var h=d.getHours(); var m=d.getMinutes(); var sec=d.getSeconds(); var ampm=(h>=12)?'PM':'AM'; if(h>12) h-=12; if(h==0)h=12; if(m<10) m='0'+m; var t=h+':'+m+':'+sec+" "+ampm; document.getElementById('show').innerHTML='setTimeout:'+t; setTimeout('time_setTimeOut()',1000); } time_setTimeOut(); </script> </body> </html>