All Posts by Email, Once a Week

Media Temple logo

CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.

help me edit this auto updating countdown script, so that it will display a message on date?

  • # October 18, 2012 at 8:26 pm

    Here’s the countdown. It restarts the countdown the day after the event, I am just wondering if there is a way to display a message on the date of the event instead of ” -1 “



    today = new Date();
    thismon = today.getMonth();
    thisday = today.getDate();
    thisyr = today.getFullYear();
    if (thismon == 9 && thisday > 31)
    {
    thisyr = ++thisyr;
    BigDay = new Date("October 31, "+thisyr);
    }
    else
    {
    BigDay = new Date("October 31, "+thisyr);
    }
    msPerDay = 24 * 60 * 60 * 1000;
    timeLeft = (BigDay.getTime() - today.getTime());
    e_daysLeft = timeLeft / msPerDay;
    daysLeft = Math.floor(e_daysLeft);
    e_hrsLeft = (e_daysLeft - daysLeft) * 24;
    hrsLeft = Math.floor(e_hrsLeft);
    minsLeft = Math.floor((e_hrsLeft - hrsLeft) * 60);
    document.write("" + daysLeft + " days til Halloween!");

    # October 23, 2012 at 10:39 am

    This reply has been reported for inappropriate content.

    Try this instead of the last line you have:
    if(daysLeft <= 0 ) {
    document.write(‘HAPPY HALLOWEEN!!!!!!!’)
    }
    else {
    document.write(“” + daysLeft + ” days til Halloween!”);​
    }

    # October 23, 2012 at 12:56 pm

    Perfect! Thank you so much =D

    _…and Happy Halloween!!!!_

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed