Skip Navigation

[Resolved] Counter down feature in Toolset?

This support ticket is created 3 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 3 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#1999247

Tell us what you are trying to do?

I would like to put a simple counter down, counting just Days, is it possible with toolset?

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#2000047

Hello, no Toolset does not provide a built-in countdown feature like this. You might need custom programming or a 3rd-party plugin to achieve something fancy. I have a simple custom shortcode to help calculate the difference between two dates from another ticket:

add_shortcode( 'format_date_difference', 'format_date_difference_func');
function format_date_difference_func($atts = [])
{
  $atts = shortcode_atts([
    'start' => '',
    'end' => '',
    'format' => '%a days',
  ], $atts);
  $datetime1 = new DateTime($atts['start']);
  $datetime2 = new DateTime($atts['end']);
  $interval = $datetime1->diff($datetime2);
  return $interval->format($atts['format']);
}

It can be used to output the number of full days between two dates. You can supply the end date only to make the calculation dynamic based on "NOW", whenever the page is loaded. The accepted date format is YYYY-MM-DD. For example:

Just [format_date_difference start="" end="2021-12-25" format="%a"][/format_date_difference] days until Christmas Eve!

It outputs a number representing the number of full days between today the end date. That means on the day before the end date you supply, this shortcode will show "0" number of days. The intention is that you would also display the number of hours, minutes, seconds, etc by changing the "format" attribute per the dateinterval documentation below. If that's not what you want, you should set the end date one day later.
https://www.php.net/manual/en/dateinterval.format.php