Showing posts with label clock. Show all posts
Showing posts with label clock. Show all posts

Feb 15, 2014

Make a Clock in Javascript



In this post we will create a simple clock that updates every second, and it is very easy to do and understand, it is a good way to go introducing us to the world of javascript.



Create the function

The first thing to do is open our favorite JavaScript editor (Sublime Text, NotePad + +, Dreamweaver, etc. ..) and we write:



function clock() {

         var dateNow = new Date();

         var hours = dateNow.getHours();
         var min = dateNow.getMinutes();
         var sec = dateNow.getSeconds();