Hi i need a simple timer for seconds which keep increment.
0 1 2 3 ....30
Can anyone help?

Not Tested:

var timer = {

    // ID of div to display the time
    divId: "myDivId",

    // Used to store the div object
    div: undefined,

    // Used to store the interval object
    interval: undefined,

    // Used to store the current time
    currentTime: 0,

    // Initialize timer
    init : function() {

        timer.div = document.getElementById(timer.divId);

        timer.interval = setInterval(function() {

            timer.currentTime = currentTime + 1;

            timer.updateTimeDisplay();

        }, 1000); // 1000 milliseconds = 1 second
    },

    updateTimeDisplay: function() {
        timer.div.innerHTML = timer.currentTime + " seconds";
    },

    stop: function() {
        clearInterval(timer.interval);
    }

};

// Initialize timer
timer.init();


// Stop timer after 100000 milliseconds
setTimeout(function() {

    timer.stop();

}, 100000);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.