# Implementing a countdown bbcode

**URL:** <https://meta.discourse.org/t/implementing-a-countdown-bbcode/246188>\
**Category:** Development\
**Created:** [November 20, 2022, 11:04am UTC](https://meta.discourse.org/t/implementing-a-countdown-bbcode/246188 "2022-11-20T11:04:32Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![marcozambi](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcozambi/32/119505_2.png) [@marcozambi](https://meta.discourse.org/u/marcozambi)\
**Post date:** [November 20, 2022, 11:04am UTC](https://meta.discourse.org/t/implementing-a-countdown-bbcode/246188/1 "2022-11-20T11:04:32Z")

</div>

Hi all!  
I would like some help for starting the development of a “countdown” bbcode that, as the name says, will display a countdown in a post.  
The idea is to translate something like this `[countdown=<iso date and time>]` into a simple textual countdown of the format `ddd:hh:mm:ss` where d is days, h is hours, m is minutes and s is seconds.

The experiments I did so far was inserting some js code to calculate the amount of days, hours and so on. I inserted it in the header part of the theme through the theme editing interface, and I can display the countdown in the js console no probs.

The tricky part, even after having read the [Developing Discourse Themes & Theme Components](https://meta.discourse.org/t/beginners-guide-to-developing-discourse-themes/93648) , is to find a way to:

- find whether the post raw text contains a `[countdown ...]` tag
- get the iso date in it and validate it
- if validation succeeds, start the countdown js function and perform text substitution in the post cooked text

I was thinking to get some inspiration from the code that performs the `[date ...]` function provided by Discourse. Would that be a valid choice? Could you suggest any better alterntive?

Thanks in advance!

---

_[View the full topic](https://meta.discourse.org/t/implementing-a-countdown-bbcode/246188)._
