We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Date Maths

Development and Programming

Matt Ellis's avatar
Matt Ellis
51 posts
16 years ago
Matt Ellis's avatar Matt Ellis

I’ve trying to create a countdown timer which counts down to the entry_date of a weblog entry. Basically the client enters a weblog event and the count down display the number of days until the event happens.

Is there a way to work out the number of days between todays date and a future weblog entry?

Moved to Plugins by Moderator

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

Matthew, Mark Bowen redid a plugin a while back: MB:// Countdown that might be helpful.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

You beat me to it 😉

I had this post open for hours today meaning to reply to it and only just got around to it.

Hope the plugin is of use on this one.

Best wishes,

Mark

       
Ingmar's avatar
Ingmar
29,245 posts
16 years ago
Ingmar's avatar Ingmar

Let us know if that helps, Matthew 😊

       
Matt Ellis's avatar
Matt Ellis
51 posts
16 years ago
Matt Ellis's avatar Matt Ellis

Yeah (nearly) works perfectly for what I need.

Is there any way to get it to get to out put ‘day’ as two figures - eg: one day left would output as 01 rather than 1?

Thanks guys!

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

I’ll let Mark answer, since it’s his plugin, moving to plugins forum.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Matthew,

Not tested but hopefully this will work :

{exp:mb_countdown date="19th September 2009" event="My Birthday"}
There are {if days <= "9"}0{/if}{days} days, {hours} hours and {minutes} minutes until {event}
{/exp:mb_countdown}

Hope that helps a bit. As I say I haven’t had time to test it so if it doesn’t work then please do let me know and I’ll take a look into it.

Best wishes,

Mark

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Actually scratch that I don’t think that will work as I haven’t added in the conditionals to the plugin. I have to go out just now but will take a look at adding in conditionals to the plugin a little later on and then upload a newer version plugin later on when I (sorry, IF I 😉 ) get it working.

Best wishes,

Mark

       
Sue Crocker's avatar
Sue Crocker
26,054 posts
16 years ago
Sue Crocker's avatar Sue Crocker

Make sure to add something like leadingzero which adds or doesn’t add a leading zero. 😊

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Actually thinking about it this should work :

{exp:mb_countdown date="19th September 2009" event="My Birthday"}
There are {if "{days}" <= "9"}0{/if}{days} days, {hours} hours and {minutes} minutes until {event}
{/exp:mb_countdown}

It’s not the exact best way of doing things but will work until I add in some code to the plugin. Should hopefully be safe as it’s only using the days variable which is already safely set in the plugin anyway.

Best wishes,

Mark

       
Matt Ellis's avatar
Matt Ellis
51 posts
16 years ago
Matt Ellis's avatar Matt Ellis

Mark! Thanks, only just got round to trying this out - works perfectly! Thanks very much.

Cheers,

Matthew

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Hi Matthew,

Excellent news. Thanks for letting me know.

When I get the chance I’ll take a look at adding it directly into the plugin instead although for now I don’t really see too much of a problem with it being done like this.

Hope everything else goes well for you.

Best wishes,

Mark

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.