KB Plugins

The best Wordpress plugins are free

Print this post

KB Countdown Widget

Please post your comments about this widget to the appropriate post in the KB Countdown category. I have disabled commenting on this page because it was getting too big.

Ever wanted to track a pregnancy, or the time until the next elections, or your baby’s precise age, or something else that will surely fascinate all your readers? Introducing the KB Countdown widget, which does just that. You give it a start date, an end date, or both. You then write in a message like this:

Janelle will have the baby in TIME_UNTIL!

In your sidebar, visitors see this:

Janelle will have the baby in 3 months and 4 days!

I’ve got several examples in the sidebar (you might need to scroll down a ways).

  • The first shows a basic use (with the default bargraph),
  • the second shows localization into German,
  • the third shows a customized bargraph (except for the crimson border, which was applied by my stylesheet),
  • and the fourth makes a table by using the advanced tags instead of the standard tags (see FAQ).

And starting with version 2.0, you can also use KB Countdown in pages or posts, like this: KB Countdown has been awesome for 1 year, 1 month, and 20 days. The world will end in 98 years, 10 months, and 11 days. Look in kb_countdown.php for instructions about this advanced use.

To download the current version or read the FAQs, go to the KB Countdown download page in Wordpress.org’s plugins database. If you have a support question about the plugin, post a comment below (but please read the FAQs first).

If you’re using this widget, go ahead and leave a comment or trackback so people can see what you’ve done with it.

Please post your comments about this widget to the appropriate post in the KB Countdown category. I have disabled commenting on this page because it was getting too big.

65 comments

1
Fabian adds
at 10:05 am on March 30, 2007 #

Hi Adam,

your widget plugin sounds great, but I’ve got some trouble running it on my own new blog. How do I set the start date and how exactly do I write the code in my sidebar, that it shows the age of somebody?

Best regards,
Fabian

2
Thus saith Adam
at 10:09 am on March 30, 2007 #

Fabian,

Since this is a widget, you don’t need to do any coding in your sidebar. You do, however, need to be using a widgets-enabled theme and have the sidebar widgets plugin running. Once you’ve activated the plugin, the countdown will show up in Presentation » Widgets. You can set your date and other options there.

Hope that helps.

3
Fabian remarks
at 12:11 pm on March 30, 2007 #

Dear Adam,

wow that was fast. I’ve activated your widget through the plugin menu, then it’s highlighted green to sign its activation. So I switch into presentation menu, but everything I see is a themes menu, a theme editor menu and header image and color menu. I could find any widgets menu at all. Maybe I did something wrong with the setup of the blog ohr your plugin… I’m very clueless. :( I’ll try to get some idea out of the workpress support forum.

Once again, thanks for your fast help.

4
Fabian adds
at 12:30 pm on March 30, 2007 #

Dear Adam,

it’s the noob again. :-D I only wanted you to know, that I succesfully solved my problem. I uploaded only your plugin and forgot to upload and activate the widget plugin from the wordpress download section.

Everything works fine now. I love your KB Countdown plugin. Thanks a lot.

5
Thus saith Adam
at 1:02 pm on March 30, 2007 #

Glad you got it working.

6
Neo exclaims
at 9:16 pm on March 30, 2007 #

Hello Adam
I’ve run into a small issue. I cannot find the widgets option under “presentation”..

7
Fabian thinks
at 1:08 am on March 31, 2007 #

Neo,

you’ve run into the same problem than I did. You need to install the “sidebar widgets” from the wordpress download section >>http://wordpress.org/extend/plugins/widgets/

8
Thus saith Adam
at 8:32 am on March 31, 2007 #

FYI Fabian,
I’m guessing from your name that you might be German. I updated the widget yesterday afternoon to v1.1, which makes translation for non-English sites easier.

9
Fabian comments
at 4:26 pm on March 31, 2007 #

Your guess is 100% correct. I hope your assumption comes realy from my name and not from my average english knowledge. But I guess it’s a bit of both. ;) I updated your widget to the new version and it’s dream. Very nice work. Thanks a lot.

Fabian

10
At0m proclaims
at 1:14 am on April 7, 2007 #

HI !
Kb-countdown have problem with localhost.

11
At0m contributes
at 1:15 am on April 7, 2007 #

img src=C:\AppServ\www\wordpress\wp-content\plugins\ widgets/kb_countdown/kb_countdown_bargraph.php

12
Thus saith Adam
at 10:43 am on April 7, 2007 #

I think I know what the problem is, but I won’t be able to look at it until later today.

13
Thus saith Adam
at 12:23 pm on April 7, 2007 #

Fixed. Download v1.5.1 from wordpress.org. I improved the way the program finds the bargraph’s URL. And in case it still does it incorrectly, I added a setting at the top of the file allowing you to manually specify the URL to the bargraph file. One of those two changes will solve your error.

14
Brad exclaims
at 6:07 pm on April 7, 2007 #

Your plugin doesn’t appear to work with the K2 theme. This theme has a built-in sidebar widgets called sidebar modules. Everything that is supposed to work with sidebar widgets is supposed to work with this as well and so far has. K2 won’t allow you to run sidebar widgets on top of sidebar modules either, can you please help?

15
At0m proclaims
at 9:14 pm on April 7, 2007 #

Thats Work ! GreaT !!

Thank you

16
Thus saith Adam
at 9:21 am on April 8, 2007 #

Brad, could you be a little more specific about what the problem is?

17
Jakob comments
at 6:48 am on April 14, 2007 #

Thanks for the nice widget! The order MONTH-DAY-YEAR is unusual in other areas of the world, could you change it to international style YEAR, MONTH, DAY? Is there a way to only show to total number of days?

18
Thus saith Adam
at 8:31 am on April 15, 2007 #

Jakob,

You could modify the order of the date fields on your own if you wish. But any order that I pick will bug somebody, so I’ll probably just leave it as is.

As for total days, that’s something I’ve been meaning to add for a while but haven’t gotten to yet. I hope to get to it soon.

19
Thus saith Adam
at 9:19 am on April 16, 2007 #

Jakob,

Download v1.6. You can now use TOTAL_DAYS_UNTIL and TOTAL_DAYS_SINCE. There’s a demo in my sidebar.

Enjoy.

20
Kevin contributes
at 6:15 am on April 19, 2007 #

Great widget…very easy to install and use! I’m using it to count down the days until we move!

[link]

(The website field wasn’t showing up in the comment form.)

21
Thus saith Adam
at 7:49 am on April 19, 2007 #

Thanks Kevin. I removed the website field for some reason, but I forgot what it was, so I’ll add it back in now.

22
James exclaims
at 3:30 pm on April 20, 2007 #

Great plugin. Using it on my blog’s main page. linked to it on my blog’s About this Blog page.

Gonna upgrade now to the new version.

cheers!

23
Derek writes
at 9:47 pm on April 20, 2007 #

Adam:

Great plug-in. One question - when I show the plug-in on my site, it drops some of the formatting of my sidebar. Any thoughts on how to fix it? See [link]

Thanks,

Derek

24
Thus saith Adam
at 10:04 am on April 21, 2007 #

Glad you guys like it. Derek, this is an issue with your theme, not the plugin. Your theme expects all widgets to be in a list format, not in a paragraph format. You would probably have the same problem if you used the text widget.

You could work around this problem by adding <ul><li> to the beginning of the countdown widget’s output and </li></ul> to the end. This would cause your theme to apply the desired background formatting, but it would also make your countdown show up as a bulleted item. Your choice.

25
RayzrShrp remarks
at 5:34 pm on April 24, 2007 #

In regards to #comment-22 and Brad not being able to get it to run under K2:

I also was unable to get it to work. I have no idea how K2 is interfacing with sidebar widgets but one thing I noticed is it lists the KB countdown item 9 times which seems odd.

26
Thus saith Adam
at 8:50 am on April 25, 2007 #

RayzrShrp:

It may be a little while to I get to it, but I’ll see if I can take a look at K2 and figure out what the problem might be.

But this sounds more like a problem with K2. If the K2 folks are claiming that their “modules” can do everything that the widgets plugin does, they are apparently incorrect. You may want to point this out to them.

27
Tony opines
at 11:24 pm on April 29, 2007 #

I noticed in example three you have a link. How did you do that?

28
Dave contributes
at 12:15 am on April 30, 2007 #

The days remaining seems to be off by at least a day.

I’m in Arizona so GMT is -7. The correct Date and Time are displayed in WordPress’s Options, General admin menu.

Today is Monday, 5/30/2007. Setting the Widget to an end date of Sunday, 5/6/2007 “should” show 6 Days remaining using the TIME_UNTIL tag. However it shows 7 Days. I am having to set the end date a day early to actualy get the correct number of days to display. Tried the TOTAL_DAYS_UNTIL tag and also displayed the same “wrong” date. Is this a bug? Or is the Plug-in counting Hours from Midnight to Midnight?

Maybe a feature Request: Ability to specify start/stop times

29
Thus saith Adam
at 8:47 am on April 30, 2007 #

Tony: Just insert the appropriate HTML, e.g. <a href=”http://www.deathclock.com/”>death clock</a>.

Dave: I’ll take a look at it soon.

30
Tony contributes
at 4:47 pm on April 30, 2007 #

I did insert the appropriate html statement in the text box, and it was stripped out and reverted back. I’ll try again.

31
Thus saith Adam
at 5:00 pm on April 30, 2007 #

Was your link in the title or in the message? Because it shouldn’t have stripped from the message, but I don’t recall whether the title strips them, I’d have to check.

32
Thus saith Adam
at 5:05 pm on April 30, 2007 #

@Dave: Downloading v2.1 should fix this. It was off by only 7 hours (most likely) because of a weird way that WP handles time zones. It probably was off because you were looking at it during the 7 hour window between when the date changed in Greenwich ans when it changed in Arizona. It should be fixed now.

I’ve been meaning to add in hours and minutes to the countdown. It may be a few more days until I get to it, though. I’m guessing that’s what you meant by “start/stop” times. (Or did you mean making it disappear/appear after a certain time?)

33
Dave adds
at 5:49 pm on April 30, 2007 #

Wow! Quick turn around! I’ll download 2.1.1 and see if it fixes the issue.

I was meaning hours and minutes (with the ability to have them show or not as desired). But now that you mention it having the ability for the Countdown to appear/dissapper at a set time would be nice.

For example in our current application you saw that we are using Event Calendar (which is working well) but a countdown that worked similar would also be nice. Be able to feed the Widget multiple countdowns and when the first date is reached that one goes away and the next in line starts automatically.

34
Dave thinks
at 6:02 pm on April 30, 2007 #

Nope. Deactivated the old plugin. Uploaded the new one. Reactivated. Went to Sidebar Widgets. Opened KB Countdown 1. Changed the end date from 5/5/2007 to 5/6/2007. Saved Changes. Viewed the Site and even Refeashed the view. The Days remaining from 4/30/2007 to 5/6/2007 says 7 Days. If you count the full current day and the full end day 7 is the correct number. 30, 1, 2, 3, 4, 5, 6. But the actualy number of days until you reach the 5/6/2007 from 4/30/2007 is really 6. 30, 1, 2, 3, 4, 5 of if you want to count it as 1, 2, 3, 4, 5, 6. Either way my perspective is to not count both the current day and the end day.

Maybe just an issue of semantics or perspecrive so maybe it really isn’t “broken”.

Reset the the Countdown to 5/5/2007 so that the real numberr of days until the event (as I count them) is showing.

Maybe the idea of being able to enter a time for the end event would assist in determing the real number of days since you could count it off the 24 hour clock. A little less granular then counting whole days.

35
Dave says
at 6:18 pm on April 30, 2007 #

Just tried the other new Countdown timer up on the Widget’s page. It does the time remaining and the ability to delete the event when it has passed. If your Widget was similar to his countdown with your cool bar graph/percent remaining would be the “ticket”. Plus your ability to add additional text and to format it would be nice.

36
Tony adds
at 10:50 pm on April 30, 2007 #

@Adam

Title. I’ll give the message portion a try.

37
Thus saith Adam
at 2:23 pm on May 1, 2007 #

Dave, something’s funny. It really should be giving you one fewer days than it is. I’m curious what version of WP and what version of PHP you’re using, just in case somebody else ends up having the same issue.

As for your comments about the countdown timer, I’ve been having the same thought.

38
Dave says
at 12:08 am on May 3, 2007 #

MySQL 4.0.18, WordPress 2.1.3, PHP 4.4.2
Running on Windows 2000 Server (IIS)

39
Thus saith Adam
at 4:05 pm on May 3, 2007 #

Thanks Dave. I don’t know whether I’ll be able to nail the problem, but if somebody else has the same problem, maybe we’ll be able to see a pattern.

40
at 10:28 am on May 8, 2007 #

hey,

i got your plugin to work, but the only issue i am having is, it screws up my sidebar. like the text is coming up at the top of the sidebar and the countdown at the bottom. any ideas?

41
Thus saith Adam
at 4:27 pm on May 8, 2007 #

It’s hard to say, since the countdown is no longer on your site. My guess is that it’s an issue with your theme. From what I can tell, the calendar, “categories,” and search things in your sidebar aren’t widgets, but are hard-coded into the theme. That would affect where the widget can show up.

I’m not sure what you mean by “the text,” since there isn’t any text in your sidebar.

Anyway, it’s not the widget, it’s your theme. Perhaps my earlier comment to Derek would be relevant.

42
Geoff contributes
at 3:14 pm on May 12, 2007 #

Great widget, once we had worked out all the options. Many thanks - see it in action at [link] until June 17th 2007 :-)

43
at 1:52 pm on May 17, 2007 #

Very cool plugin, thank you!

44
Matthew writes
at 8:26 am on May 22, 2007 #

When I use more than widget they both use the same info as the first one, even though they are obviously setup up differently.

45
Matthew opines
at 8:28 am on May 22, 2007 #

To further expand on that even if the 1st widget isn’t being used the additional coundowns still pull their data from that first configured widget.

46
Thus saith Adam
at 10:45 am on May 22, 2007 #

Yes, this is a problem caused by v2.2 of Wordpress. UPgrade to v2.3 of the plugin.

47
Chris says
at 12:02 am on June 10, 2007 #

Hey, I’m trying out your widget, and I was wondering if there was a way to make each countdown indent four spaces, to match the default formatting of the other default widgets? I tried putting four ‘ ’ codes in front of each entry, but this only indents the first line.

Also, how can I make it so that there’re no blank lines between each countdown?

48
Thus saith Adam
at 8:52 am on June 10, 2007 #

Chris,

Look in your HTML source. The other widgets present each item as a list. You are presenting your countdowns as unformatted text. Wrap your countdown text (in the widget options) in this code:

<ul><li>(countdown stuff goes here)</li></ul>

As for the blank lines, that’s a result of your theme’s CSS–not the widgets themselves. I took a look at your theme, and it looks like you could try one of these two solutions (pasted into the end of style.css). If these work, great, but if not, tinkering with the theme is sort of your job, so I’ll leave it to you to figure out.

This will do exactly what you want, but you need to put in one entry for each countdown except for the last one. You have them ordered as countdown 1, countdown 3, countdown 2, so this is what you would need:

div#sidebar li#kb-countdown-1{margin-bottom:0;}
div#sidebar li#kb-countdown-3{margin-bottom:0;}

This next solution is simpler. You only need one line. The drawback is that it will make your last countdown a little too close to the “Meta” widget. But I recommend this one for ease of use.

div#sidebar li.widget_kbcountdown{margin-bottom:0;}

49
Chris proclaims
at 10:52 pm on June 10, 2007 #

Thanks, Adam, the list modification did the trick! All nice and indented now. And I did take the 2nd, easier, spacing suggestion…the narrow spacing between the last countdown and Meta was easily fixed by a break code.

Thanks so much for taking the time to make your suggestions, even about the theme…I know very little about coding or php in general, just enough to stay in deep trouble, so I would’ve been pretty near helpless as to dealing with my fine-tuning. Very kind of you.

I still have blank lines between each countdown…I suppose this is because it leaves a space for the heading even when leave it blank? I don’t suppose there’s a way around this? Picky, aren’t I?

50
Chris remarks
at 5:57 am on June 12, 2007 #

One more small point…sometimes when I click on the box to edit one of the countdowns, the form pops up and the X to close the form and the titlebar to drag the form are halfway up above the top border of the browser window, so I can barely get my cursor onto the X to save my settings.

THIS morning the X and titlebar are ABOVE the top border of the window, so today I can’t save any settings. I’m using IE 7…I’m about to try an alternate browser just to save the settings. Is this a problem you know about, or is it just me? Is there some alternate way to move the window so I can close it?

51
Chris adds
at 5:59 am on June 12, 2007 #

Update…same problem for Netscape and Firefox.

52
Thus saith Adam
at 7:22 am on June 12, 2007 #

Chris: You don’t need to click the X. Just click anywhere outside the options box. That doesn’t really fix the problem of the box being too big, which I’ll need to look at, but it will allow you to save your settings.

53
Chris adds
at 7:34 am on June 12, 2007 #

Oh! Duh. Sorry if my questions are very beginner-y, I’m terribly new but learning. Thanks for the tip.

54
Aaron Brazell says
at 6:19 pm on June 16, 2007 #

This TOTALLY needs to be updated to work on WP 2.2 which has been out over a month now.

55
Thus saith Adam
at 8:47 am on June 17, 2007 #

It totally works on WP 2.2, and has for some time. What error are you getting, and what version of PHP are you using?

56
KC comments
at 8:01 am on June 21, 2007 #

It seems that this very newest 2.2.1 has broken the display of the widget. The admin of it seems perfectly fine… but it shows nothing, like an empty widget.

Aaron, yes it does (did) work on 2.2 perfectly for me.

57
Thus saith Adam
at 8:51 am on June 21, 2007 #

KC: Go download the updated version. It seems that the WP developers like to screw with the widgets API on every WP update lately, so I had to change a few things for it to be compatible with 2.2.1.

I have NOT installed 2.2.1 on my own system for testing, so please let me know whether my fix works. It should work in theory, but reality and theory are distant cousins at best.

58
Nicole says
at 3:30 pm on June 21, 2007 #

Had the same problem by upgrading to 2.2.1.
Thanks for the quick update, great service!
FYI: now there’s only one little, small bug (no problem for me), that the widget is called “KB Advanced RSS1″ and not “KB Countdown”.
Don’t know what the prob could be if one has installed both widgets?! I have only KB Countdown installed.

BTW: you should/could update; for me there were probs with the WYSIWY-editor, now it’s solved (was a fresh installation of 2.2).

Again:great work, go on like this, wish you all my best!

59
Thus saith Adam
at 3:34 pm on June 21, 2007 #

Thanks for catching that, Nicole. That’s what I get for going too fast and trying to update two widgets at once. It’s fixed now.

I hadn’t updated because I use WP-MU, not plain WP. But I just updated MU today, which has the same changes to widgets.php, so I’ve checked and this should work fine now.

60
Arnulf proclaims
at 6:43 am on June 24, 2007 #

Hi!
countdown is a very nice widget. I installed it today with wordpress 2.2.1 running.
Everything looks ok except the bargraph is wrong (in my opinion).
I tested it with several dates. But even a few days remaining shown only a few pixels in the progress bar.

if it helps: I’m running WP 2.2.1 on a german server.

Arnulf

61
Thus saith Adam
at 8:53 am on June 24, 2007 #

I assume that you set both a start and end date. If you set only one of the two, the bargraph won’t look right.

If you gave your URL, I could look for myself, but as you didn’t, there’s not much I can say other than to check that you set both dates correctly.

62
Arnulf thinks
at 9:09 am on June 24, 2007 #

sorry, i’ve forgot to give you the (temporary) url:
[link]

start date is (month-day-year) 4-24-2007
end date is (month-day-year) 5-16-2008

63
Thus saith Adam
at 9:15 am on June 24, 2007 #

Hmm. That is weird. I’ll have to take a look at the code, but it might be a couple days.

64
Arnulf comments
at 9:21 am on June 24, 2007 #

don’t hurry. I’m still busy to convert my old page into this new style.
Counting down the days still works. It’s only the progress bar.

65
Arnulf contributes
at 10:04 am on June 24, 2007 #

oops…. I’ve done a great mistake….
your calculation is quite right. Of course the bar is counting correct because starting with today, the bar has to show the beginning….

sorry.

(shame on me)

Additional commenting has been turned off for this post. I probably explain why above. Maybe you should look at the post (or at the last comment by me) to see where you should post your comment since you cannot do it here.