The concept is straightforward with JavaScript. To create a countdown, you just need the current time and the target end time.
The basic idea in pseudo-code looks like this:
Get the current time in seconds: getCurrentDate().
Specify the target time in seconds: getUptoDate.
Calculate the remaining time by subtracting the current time from the target time: getUptoDate - getCurrentDate.
This gives the remaining time in seconds. From there, you can easily convert it into days, hours, minutes, and seconds for display.
The pseudo-code is meant to illustrate the logic. You can find actual implementation examples online, and even basic language models can generate the full code for you.