WordPress.org

Ready to get started?Download WordPress

Forums

Javascript in posts/pages (3 posts)

  1. senrable
    Member
    Posted 8 years ago #

    I want to run a javascript to calculate the amount of time left until a date. I have the script, but it won't display on my page.

    The script is as follows:

    <SCRIPT language=JAVASCRIPT>
    today = new Date();
    BigDay = new Date("October 1, 2008")
    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 " + hrsLeft +" hours and " + minsLeft + " minutes left");
    </SCRIPT>

    The page is here: http://www.senrable.com/blog/?page_id=73

  2. moshu
    Member
    Posted 8 years ago #

  3. senrable
    Member
    Posted 8 years ago #

    Thanks, I actually used one where I didn't have to create a separate file by putting a reference in the header. Thank you, though!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags