Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Top Posters

Who's Online (1)

Powered by Vanilla. Made with Bootstrap.
Basic Clock Code
  • Xin
    Posts: 3,251
    Ive been learning javascript so i will be posting the code i learn!
    <html>
    <head>
    <title>Write the Date</title>
    <script type=\"text/javascript\">
    <!-- hide me from older browsers

    // get the date information
    //
    var today = new Date();
    var the_day = today.getDate();
    var the_month = today.getMonth();

    var the_hour = today.getHours();
    var the_minutes = today.getMinutes();
    var the_seconds = today.getSeconds();


    // correct for the month starting from zero
    //
    the_month = the_month + 1;

    // create the string you want to print
    //
    var the_whole_date = the_month + \"/\" + the_day + \" \";
    var the_whole_time = the_hour + \":\" + the_minutes + \":\" + the_seconds;
    // show me -->
    </script>
    </head>
    <body>

    Right now it's:

    <script type=\"text/javascript\">
    <!-- hide me from older browsers

    // write the date
    //
    document.write(the_whole_date);
    document.write(the_whole_time);

    // show me -->
    </script>

    </body>
    </html>
    Xin