1 cubano61 May 23, 2007 19:29
3 cubano61 May 25, 2007 16:30
Thanks for the reply. Well, it shouldn't really matter as I really just want to countdown days not hours and minutes. I simply want to say "x days left before the big event" at the bottom of the blog post. (Maybe white text over a colored rectangular box, but nothing fancy.) I wish I knew how to write plugins! :-)
4 personman May 25, 2007 16:43
Ok, cool. I'll try to make a little plugin that does this. We'll start with just a plain date and maybe add an option to use javascript in version 2.
5 cubano61 May 25, 2007 17:56
Wow--that was fast! Sounds great!! I know others would like minutes and seconds, but for this particular need I have, # of days make more sense.
Since it's going to be embedded in a blog post, it would be nice if it looked a little flashy so it had that "dynamic" look to it (as opposed to it saying it was going to be x # of days away at the time of the post and then that # remaining static or static-looking.) I know this seems counter-intuitive to what a blog post usually is, but it would be helpful in this situation. Thanks again!
6 personman May 25, 2007 18:09
I'm not sure I follow. What would make it look dynamic if there were no minutes and seconds? We can style it with css to make it stand out from the rest of the post, if that's what you mean.
7 cubano61 May 25, 2007 18:58
Good point! Those minutes and seconds are helpful, after all. :-) I guess I was thinking of something like the <blink> tag. (Does anyone even use that anymore?) Anything you can provide would be appreciated and I'm sure others would find it useful. Thanks again.
8 personman May 25, 2007 19:11
I'm not sure when I'll be able to start this. I'll be gone this weekend, and I really should finish the Wordpress importer plugin before I start on something else. If you need it sooner than that, you can visit AstonishMe.co.uk and hire the plugin done in a hurry.
9 cubano61 May 25, 2007 20:53
Thanks, personman. No rush. The countdown-to date is more than a month away. I really appreciate your helpfulness. (I added to your rep points.) Have a great weekend!
10 personman May 25, 2007 20:57
Thanks. If you don't hear from me in about a week, post here again to remind me. :)
11 personman May 27, 2007 22:09
cubano61,
I had some time to play around with this. Here's an example:
http://brendoman.com/dev/193/index.php?blog=2
It uses javascript to turn a date into a countdown. You simply add something like this to a post:
<span class="countdown">May 31, 2008 7:00 pm</span>
And the javascript finds anything with a class of "countdown" and runs the conversion once per second. You can have more than one countdown on a page (or even in a single post) and you can even add a countdown to your sidebar by editing the skin.
If a user has javascript disabled, then they'll just see the date, exactly as you posted it. I wanted to calculate the days remaining in php, but the problem is that the usual way to do this, a renderer, only runs when the post is created or updated, and then it's cached. So that won't work.
I think the javascript way works ok. It even does pluralization correctly. :)
Now, there are some limitations.
1. I didn't calculate months remaining. It jumps straight from days to years. With a different number of days in each months, it gets a little tricky.
2. I don't have a way to customize the "event has arrived" message. I'm sure it can be done, it will just make the code that has to be posted a bit more complex.
3. This won't work when js is disabled, as I mentioned above.
4. When you post you have to give it a valid date format. It will accept [url=http://www.cev.washington.edu/lc/CLWEBCLB/jst/js_datetime.html]anything that works with Date()[/url].
5. I don't yet have a way to customize the text that appears before and after the countdown. The solution to this will be related to #2 above.
So, what do you think so far?
12 jibberjab Jun 06, 2007 03:45
I just happened to come across this site today. You might find it useful...
http://www.clocklink.com/ENG/gallery_count.htm
jj.
13 baileyjs Jun 12, 2007 14:18
Beats me where I found this, but I am using multiple instances of this on a stub for a site I'm developing. Put this in whatever <div /div> you want.
<?php
$target = mktime(0, 0, 0, 11, 6, 2007) ; // hrs, min, sec, mth, day, year,
$today = time () ;
$difference =($target-$today) ;
$days =(int) ($difference/86400) ;
print "2007 Connecticut General Election: <br/> <span style=\"color: red;\">$days</span> days from today";
?>
I hard coded it into the stub, but it would be simple enough to make it into an include();. I'm not smart enough to turn it into a plugin.
Do you want it to be a) constantly running, like a stopwatch, or b) should the number only change when you reload the page? a) requires your readers to have javascript enabled, but it looks cooler. b) is simpler to do and will always work. There's not a way to do this in b2evolution right now, but I think a plugin could add this functionality.