Table of Contents
JavaScript Date Object Extensions: Examples
Comparing dates
Date.compare(new Date(), new Date(1969, 3, 29)); // returns difference in milliseconds new Date().compare("09/17/2012"); // same as above using the instance method
Identifying a leap year
Date.leapYear(1999); // returns false new Date().isLeapYear(); // same as above with the instance method, using current date.
Date arithmetics
Date.addDate(new Date(), Date.DAY, -1); // subtracts 1 day from the current date new Date().add(Date.MONTH, 10); // adds 10 months to the current date.
Back to Date Extensions