-1

I am using this code:

xtype: 'datefield',
anchor: '100%',
fieldLabel: 'From',
name: 'from_date',
minValue: new Date(2015, 2, 31)

I want to pass the minValue config parameter as the last day of the previous month.

Its allowed value might obviously be 28, 29, 30 or 31.

Again how to change the month.

To be more clear: if I open the date picker in April it offers me to select the value from 31st of march to the last date of the calendar.

abarisone
  • 3,707
  • 11
  • 35
  • 54
sparsh610
  • 1,552
  • 3
  • 27
  • 66

2 Answers2

1

You can solve the issue in this way:

//you get the current date
currentDate = new Date();

//now get the first day of the current month
firstDayOfCurrMonth = Ext.Date.getFirstDateOfMonth(currentDate);

//Then subtract exactly one day
minValue = Ext.Date.subtract(firstDayOfCurrMonth, Ext.Date.DAY, 1);

In fact the subctract method:

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.

abarisone
  • 3,707
  • 11
  • 35
  • 54
0

you could use the getLastDateOfMonth method for set config, for eg

minVlaue = Ext.Date.getLastDateOfMonth(new Date(2015, 2, 31))
Naresh
  • 632
  • 4
  • 19
newmount
  • 1,921
  • 1
  • 12
  • 10
  • need last date of previous month ... .. to be more clear ... if i open the date picker in april ... it offers me to select the value from 31st of march to the last date of the calendar. i want to vote down it but didnt have 125 reputation to do it. – sparsh610 Mar 16 '15 at 05:05
  • Good luck for you earn 125 reputations soon, anyway regarding your question - you just have to figure out how to pass a variable date(previous months date) as an argument for getLastDateOfMonth function... – newmount Mar 16 '15 at 05:22