if(day.toString().length == 1) day = "0" + day; if(hou.toString().length == 1) hour = "0" + hou; if(min.toString().length == 1) min = "0" + min;
<script>function foo(num) { return num < 10 ? '0' + num : num; } var date = new Date(); document.write( foo( date.getHours() ) + ':' + foo( date.getMinutes() ) + ':' + foo( date.getSeconds() ) );</script>