Relógio Atualizado segundo a segundo

<html>
    <head>
        <title>
            Clock in Javascript
        </title>
        <script>
            function zeroPad( value )
            {
                return ( value.length == 1 ) ? '0' + value : value;
            }
            function clock( )
            {
                var now     = new Date( );
                var hours   = zeroPad( now.getHours( ).toString( ) );
                var minutes = zeroPad( now.getMinutes( ).toString( ) );
                var seconds = zeroPad( now.getSeconds( ).toString( ) );
                        
                document.getElementById( 'time' ).innerHTML = hours + ':' + minutes + ':' + seconds;
                setTimeout( 'clock( )', 1000 );
            }
        </script>
    </head>
    <body onload="clock( )">
        <span id="time"></span>
    </body>
</html>

0 comentários:

Postar um comentário

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More