Paste the Javascript I wrote first Code For more information, see.
/* Get the date after the date, month, day, and other plus numbers */
Date. Prototype. dateadd = function (interval, number)
{
VaR d = this;
VaR K = {'y': 'fullyear ',
'Q': 'month ',
'M': 'month ',
'W': 'date ',
'D': 'date ',
'H': 'urs ',
'N': 'minutes ',
'S ': 'seconds ',
'Ms': 'milliseconds '};
VaR n = {'q': 3,
'W': 7 };
Eval ('d. set '+ k [interval] +' (D. get '+ k [interval] +' () + '+ (n [interval] | 1) * Number) + ')');
Return D;
}
/* Calculate the date, year, month, and day of the two dates */
Date. Prototype. datediff = function (interval, objdate2)
{
VaR d = this, I = {},
T = D. gettime (), T2 = objdate2.gettime ();
I ['y'] = objdate2.getfullyear ()-D. getfullyear ();
I ['q'] = I ['y'] * 4 + math. Floor (objdate2.getmonth ()/4)-math. Floor (D. getmonth ()/4 );
I ['M'] = I ['y'] * 12 + objdate2.getmonth ()-D. getmonth ();
I ['ms'] = objdate2.gettime ()-D. gettime ();
I ['W'] = math. Floor (T2 + 345600000)/(604800000)-math. Floor (t + 345600000)/(604800000 ));
I ['D'] = math. Floor (T2/86400000)-math. Floor (T/86400000 );
I ['H'] = math. Floor (T2/3600000)-math. Floor (T/3600000 );
I ['n'] = math. Floor (T2/60000)-math. Floor (T/60000 );
I ['s '] = math. Floor (T2/1000)-math. Floor (T/1000 );
Return I [interval];
}
Dateadd Method
Returns the date object with the specified interval added.
Dateobj. dateadd (Interval, number)
Parameters
Dateobj
Required. ArbitraryDateObject.
Interval
Required. String expression, indicating the time interval to be added. For values, see the "Settings" section.
Number
Required. Numeric expression, indicating the number of time intervals to be added. A numeric expression can be a positive number (to get the future date) or a negative number (to get the past date ).
Datediff Method
Returns the time interval between two date objects.
Dateobj. datediff (Interval, dateobj2)
Parameters
Interval
Required. String expression used for calculationDate1AndDate2Time interval. For values, see the "Settings" section.
Dateobj, dateobj2
Required. Date object. Two date objects used for calculation.
Set
IntervalParameters can have the following values:
Settings | & Lt; th width = "75%" & gt; description & lt;/th & gt;
Y |
year |
q |
quarter |
m |
month |
d |
day |
W |
week |
H |
hour |
n |
minute |
S |
seconds |
MS |
millisecond |