I am trying to add a countdown timer to a page. The date to which it should countdown will depend on the CMS Collection Item for the page. I can’t figure out how to set the date to the proper time. This is as close as I have gotten:
var timer;
// CURRENT DATE AND TIME
var now = new Date();
var then = new Date("<Start Time>"); // <Start Time> is added as a field from the CMS item
var compareDate = new Date(then) - now.getDate();
In the published site, this is rendered as:
var timer;
// CURRENT DATE AND TIME
var now = new Date();
var then = new Date("May 10, 2022");
var compareDate = new Date(then) - now.getDate();
The problem is that the date field has a time, but that is not reflected. How can I specify the format of the field as it is inserted in the custom code?
Here is my site Read-Only: LINK
(how to share your site Read-Only link)