Haunt Forum banner
1 - 2 of 2 Posts

41 Posts
Discussion Starter · #1 ·
@HauntingVS @RoxyBlue

The 'Days until Halloween!' countdown timer uses a date that is hard-coded in JavaScript and must be updated by a site admin after Halloween each year. I am providing a code fix for the countdown so that it will always be current. With this code change it will automatically start counting down to next year's Halloween on November 1st. I am providing this code to use free of charge by anyone without any expectation of compensation.

Simply replace the highlighted code in the image with the replacement code below.
Rectangle Font Screenshot Parallel Software

Replacement code:
// Get the next date that is Halloween relative to now
var nextHalloween = new Date(); 

// Add one year if after Halloween in the current year (Nov or Dec), month is zero based
if (nextHalloween.getMonth() > 9) {
    nextHalloween.setFullYear(nextHalloween.getFullYear() + 1);

nextHalloween.setMonth(9, 31); // Set date to Oct 31, month is zero based
nextHalloween.setHours(0,0); // Set time to 12:00 am

// Set the date we're counting down to
var countDownDate = nextHalloween.getTime();
1 - 2 of 2 Posts