Post: [Help] Making a timer for a website
04-16-2011, 02:48 PM #1
(adsbygoogle = window.adsbygoogle || []).push({});
Hello people, need some help :lol:

I want to make a timer for my website, just a simple one that will count up, can you do it using just Javascript/JQuery? If so can anyone tell me how? I only know HTML and CSS, i'm a noob at the rest.

Here's an example of what i want: You must login or register to view this content. :megusta:
You must login or register to view this content.
04-16-2011, 02:50 PM #2
Fail
I Break The Rules.
Edit. NVM realized exactly what you wanted.
04-16-2011, 02:58 PM #3
Default Avatar
Oneup
Guest
Originally posted by ccarlsen View Post
Hello people, need some help :lol:

I want to make a timer for my website, just a simple one that will count up, can you do it using just Javascript/JQuery? If so can anyone tell me how? I only know HTML and CSS, i'm a noob at the rest.

Here's an example of what i want: You must login or register to view this content. :megusta:
You must login or register to view this content.

Well counting up isn't much different then counting down and that's really the only example I have from something I had to do.


    document.getElementById("countdown").innerHTML = date_countdown();


    var date_countdown = function () {
var endofterm = new Date(2011, 2, 29, 11, 45, 00);
var now = new Date();

var totaltime = endofterm.getTime() - now.getTime();

totaltime = Math.floor(totaltime / 1000);
var days = Math.floor(totaltime / 86400);
totaltime = totaltime % 86400;

var hours = Math.floor(totaltime / 3600);
totaltime = totaltime % 3600;

var mins = Math.floor(totaltime / 60);
totaltime = totaltime % 60;
var secs = Math.floor(totaltime);

var timeleft = "";


if (days != 0) {
timeleft += days + "day" + ((days != 1) ? "s" : "") + ", ";
}

if (days != 0 || hours != 0) {
timeleft += hours + " hour" + ((hours != 1) ? "s" : "") + ", ";
}


if (days != 0 || hours != 0 || mins != 0) {
timeleft += mins + " minute" + ((mins != 1) ? "s" : "") + ", ";
}
setTimeout("date_countdown()", 1000)
timeleft += secs + " seconds";
document.getElementById("countdown").innerHTML = timeleft
return timeleft;
}



But
    setTimeout("date_countdown()", 1000)


Is your timer

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo