Copy the codeThe code is as follows:
= function(interval,number)
{
var d = this;
var k={'y':'FullYear', 'q':'Month', 'm':'Month', 'w':'Date', 'd':'Date', 'h':'Hours', 'n':'Minutes', 's':'Seconds', 'ms':'MilliSeconds'};
var n={'q':3, 'w':7};
eval(''+k[interval]+'('+k[interval]+'()+'+((n[interval]||1)*number)+')');
return d;
}
= function(interval,objDate2)
{
var d=this, i={}, t=(), t2=();
i['y']=()-();
i['q']=i['y']*4+(()/4)-(()/4);
i['m']=i['y']*12+()-();
i['ms']=()-();
i['w']=((t2+345600000)/(604800000))-((t+345600000)/(604800000));
i['d']=(t2/86400000)-(t/86400000);
i['h']=(t2/3600000)-(t/3600000);
i['n']=(t2/60000)-(t/60000);
i['s']=(t2/1000)-(t/1000);
return i[interval];
}
dateAdd method
Returns the date object where the specified time interval has been added.
(interval, number)
parameter
dateObj
Required option. Any Date object.
interval
Required option. A string expression that indicates the time interval to be added. For values, see the Settings section.
number
Required option. Numeric expression, indicating the number of time intervals to be added. Numeric expressions can be positive (get future dates) or negative (get past dates).
dateDiff method
Returns the time interval between two date objects.
(interval, dateObj2)
parameter
interval
Required option. A string expression that represents the time interval used to calculate date1 and date2. For values, see the Settings section.
dateObj, dateObj2
Required option. Date object. Two date objects used for calculation.
set up
The interval parameter can have the following values:
set up | describe |
---|---|
y | Year |
q | Quarterly |
m | moon |
d | day |
w | week |
h | Hour |
n | minute |
s | Second |
ms | millisecond |