Wanted- Easy countdown script

Everything related to the visual and coding aspects of websites.
Destinie
Posts: 3357
Joined: Mon Aug 15, 2011 5:27 pm
Location: Columbia, MD
Contact:

Wanted- Easy countdown script

Post by Destinie »

Does anyone know of a really easy countdown script? (Preferably jQuery) And one I can just plug in and easily customize? I was trying to get one up for a site the other day and I couldn't really find one that would actually work. I did find a pretty popular jQuery countdown but it seems it is out of date(?). So I was just wondering if anyone here had any ideas.

Thanks!
dubiousdisc
Administrator
Posts: 2535
Joined: Thu Jun 21, 2012 5:49 pm
Contact:

Re: Wanted- Easy countdown script

Post by dubiousdisc »

I found this, haven't tried it but the last update was in August and it looks easy and nice :o
Destinie
Posts: 3357
Joined: Mon Aug 15, 2011 5:27 pm
Location: Columbia, MD
Contact:

Re: Wanted- Easy countdown script

Post by Destinie »

Ah! That's the one I tried and couldn't get to work. >_<
anon

Re: Wanted- Easy countdown script

Post by anon »

Would you prefer using a widget?
Destinie
Posts: 3357
Joined: Mon Aug 15, 2011 5:27 pm
Location: Columbia, MD
Contact:

Re: Wanted- Easy countdown script

Post by Destinie »

If I could customize it. I wanted one that I could customize the look so it would fit the theme of our website. (It's for our wedding website)
Mikari
Posts: 3159
Joined: Thu Jun 21, 2012 6:30 pm
Location: Coruscant
Contact:

Re: Wanted- Easy countdown script

Post by Mikari »

Did you try just using a JS script that retrieves the computer date and subtracts/adds a set date from a variable? Unless you don't want to use the computer clock, I'm pretty sure there's a code that can retrieve the current time from the server instead.

Edit 1: Never mind, I've been meaning to make my own countdown script anyway. give me a little while and I'll finish typing it up.

Edit 2: I've seen you use Javascript befre for the Cooro quiz and the poke Impsum so I'll just post the code and I'm sure you'll know what to do with it. Here you go, I just finished typing it and math isn't my strong point so let me know if I messed up any calculations. I tested it though so it should be fine. You can put it on a popup or dysplay it on the site, you can ever use pictures for the numbers if you want, just add in the ifs for the image codes, or if you want to keep it simple and easy, use CSS on a form to display the information. I have it all explained in my notes page. The variables on top that start with next are the date you're counting towards. I fixed it so that January would be month 1 rather than month 0 like in default JS. I'm certainly not a programing expert so feel free to improve on anything.

Code: Select all


var nextday = 5;
var nextmonth = 11;
var nextyear = 2013;

var thedate;
var thisday;
var thismonth;
var thisyear;

var newday;
var newmonth;
var newyear;
var daysleft;

var countdown;

thedate = new Date();
thisday = thedate.getDate();
thismonth = thedate.getMonth();
thismonth = thismonth+1;
thisyear = thedate.getFullYear();

newday = nextday - thisday;
newyear = nextyear - thisyear;
newmonth = nextmonth - thismonth;

if (thismonth == 1 || thismonth == 3 || thismonth == 5 || thismonth == 7 || thismonth == 8 || thismonth == 10 || thismonth == 12 ) { daysleft=30; }

if (thismonth == 4 || thismonth == 6 || thismonth == 9 || thismonth == 11 ) { daysleft=29; }

if (thismonth == 2) { daysleft=27; }

if (thismonth == 2 && thisyear==2012) { daysleft=28; }
if (thismonth == 2 && thisyear==2016) { daysleft=28; }
if (thismonth == 2 && thisyear==2020) { daysleft=28; }
if (thismonth == 2 && thisyear==2024) { daysleft=28; }

if (newday<0) { newmonth=newmonth-1; newday=newday+daysleft; }

if (newmonth<0) { newyear=newyear-1; newmonth=newmonth+11; }


if (newyear<0) { countdown="The date has passed."; } else 
{ countdown="There are " + newday + " days, " + newmonth + " months and " + newyear + " years until event."; }

function countup() { alert(countdown); }

Destinie
Posts: 3357
Joined: Mon Aug 15, 2011 5:27 pm
Location: Columbia, MD
Contact:

Re: Wanted- Easy countdown script

Post by Destinie »

Thanks, Mikari! I will have to try this out and I'll let you know if it works. :3 I'm not very good at Javascript and the code I use for the quizzes are some really old codes I've had on my HD since...2000-something. DX I could probably teach myself some JS an try to refactor it.

Anyway, thanks again! :D
Mikari
Posts: 3159
Joined: Thu Jun 21, 2012 6:30 pm
Location: Coruscant
Contact:

Re: Wanted- Easy countdown script

Post by Mikari »

Let me know if you need extra info. I tested it on my comp so it should be okay.
Destinie
Posts: 3357
Joined: Mon Aug 15, 2011 5:27 pm
Location: Columbia, MD
Contact:

Re: Wanted- Easy countdown script

Post by Destinie »

This is late but I did get a countdown script working! Thanks for your help. ^_^ It's a really simple one that just counts down the days.

I was trying to find the details on your site but it looks like you moved it? ;o;
Mikari
Posts: 3159
Joined: Thu Jun 21, 2012 6:30 pm
Location: Coruscant
Contact:

Re: Wanted- Easy countdown script

Post by Mikari »

It's all still there. Late reply but for next time http://piratesboard.net/mikari/date.php
Post Reply