The dateDiff function uses the following arguments.
Argument | Description |
expD1 | The first date object. |
expD2 | The second date object. |
type |
Optional. Determines the format of the returned value.
|
The dateDiff function returns the absolute value of the difference between the two dates passed to the function; therefore, the order in which the dates are passed does not matter.
n/a
The following lines of code
var myDate1 = "1/1/2000";
var myDate2 = "1/1/2002";
document.write( "From " + myDate1 + " to " + myDate2 + " is " +
JSV_dateDiff(JSV_convertDateString(myDate1,1), JSV_convertDateString(myDate2,1)) +
" days.");
var dateNow = new Date();
var y2000 = new Date(2000,0,1,0,0,0);
document.write( "There are " +
JSV_dateDiff(dateNow, y2000, 'h') +
" hours " +
(dateNow > y2000 ? "in" : "until" ) +
" the year 2000.");
produce
Copyright © 1998-2000 Roaring Fork Software. All rights reserved.