I have a countdown timer on my Wordpress site. For reference I used this tutorial. I call/include the .js from a child theme via the footer of my site.
Currently the tutorial has me inserting the countdown timer via <span id="countdown"></span>.
I would like to insert the countdown timer instead, with a shortcode, that contains a variable to be parsed into the .js to set the target date.
Here is the relevant line of code from the js file, with the static/hard coded date. This is where I want to forward my variable to.
var target_date = new Date("Aug 15, 2019").getTime();
This way I can use a single .js include to create multiple countdown timers.
E.g. Shortcode: [Countdown Timer target="Aug 15, 2019"]
How do I get Wordpress to recognise the shortcode, load the span id and parse the variable to set the target date/time?
Note: I don't mind installing a plugin if there is complexity having the shortcode work. My main requirement is to be able to parse a variable, so if it can be done some other way I'd be happy to look into that.