I have the following date field i want to get date of one day before , how can i get that ? In my form panel
items: [{
fieldLabel: 'Start Date',
name: 'fromdate',
ref: '../fromdate',
id: 'fromdate',
vtype: 'daterange',
value: new Date(),
endDateField: 'todate' // id of the end date field
}, {
fieldLabel: 'End Date',
name: 'todate',
id: 'todate',
vtype: 'daterange',
value: new Date(),
startDateField: 'fromdate' // id of the start date field
}]
Today I am getting 03/23/2011 but I want 03/22/2011 How I can get 03/22/2011?
Speaking ExtJS language, you can use Ext.Date library for manipulation dates. For example:
Ext.Date.add (new Date(),Ext.Date.DAY,1)
Depending on your code logic, you can modify the default value of date field by several ways:
1) In the item's value configuration:
{
...
vtype: 'daterange',
value : Ext.Date.add (new Date(),Ext.Date.DAY,1),
fromDateField: 'fromdate',
...
}
2) During the component's event. Basically, ExtJS containers have initComponent method which is the most first running, but be sure to set your code after callParent() method in order to access items collection. Example:
initComponent: function() {
...
this.callParent(arguments);
this.items.getByKey('fromdate').value = Ext.Date.add (new Date(),Ext.Date.DAY,1);
...
}
Try this:
new Date().add(Date.DAY, -1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With