Ext.DateView source...singleton
Provides a convenient method for performing basic date arithmetic. This method does not modify the Date instance being called - it creates and returns a new Date instance containing the resulting date value.
Examples:
// Basic usage:
var dt = Ext.Date.add(new Date('10/29/2006'), Ext.Date.DAY, 5);
console.log(dt); // returns 'Fri Nov 03 2006 00:00:00'
// Negative values will be subtracted:
var dt2 = Ext.Date.add(new Date('10/1/2006'), Ext.Date.DAY, -5);
console.log(dt2); // returns 'Tue Sep 26 2006 00:00:00'
// Decimal values can be used:
var dt3 = Ext.Date.add(new Date('10/1/2006'), Ext.Date.DAY, 1.25);
console.log(dt3); // returns 'Mon Oct 02 2006 06:00:00'
Available since: 4.0.0
Parameters
- date : Date
The date to modify
- interval : String
A valid date interval enum value.
- value : Number
The amount to add to the current date.
Returns
- Date
The new Date instance.
例子:
/**
* 一周内的
*/
function aa(){
var dt = new Date();
var wd = Ext.Date.add(dt, Ext.Date.DAY, -7);
var sd = Ext.Date.format(wd, 'Y-m-d H:i:s');
var ed = Ext.Date.format(dt, 'Y-m-d H:i:s');
alert(sd);
alert(ed);
return false;
}