countdown

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

countdown

Post by Vegan »

On my IT home page, http://www.windows-it.tk I have the expiry dates manually entered into a table.

So why not mechanize the table with a date calculation in JavaScript

XP expires April 8, 2014 which is 1080 days from now, obviously if it is expired the cell should say so

I have other versions of Windows listed and they have differing dates that need to be altered as well

Code: Select all

function days_between(date1, date2) {
    // The number of milliseconds in one day
    var ONE_DAY = 1000 * 60 * 60 * 24;
    // Convert both dates to milliseconds
    var date1_ms = date1.getTime();
    var date2_ms = date2.getTime();
    // Calculate the difference in milliseconds
    var difference_ms = Math.abs(date1_ms - date2_ms);
    // Convert back to days and return
    return Math.round(difference_ms/ONE_DAY);
}


Any helpful code snippets I can leverage?
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
Post Reply