As far as formatting as you have mentioned (using .toString())
you'll have to use something similar to the answers found in
this StackOverflow discussion to handle that.
The dates work now. I have a datepicker on inout element whihc is not picking up this date..
<input style="width:6em" data-bind="datepicker: searchBeginDate" />
And knockout model I have set like this...
self.searchBeginDate = ko.observable(firstDayofMonth());
self.searchEndDate = ko.observable(lastDayofMonth());
In the input box both show today's date only.. Am I doing this correctly?
I haven't used KnockOut to bind a DatePicker previously. Are each of your your functions that you have within your observable method returning values, ie :
function getLastDayOfMonth(){
var today = new Date();
return new Date(today.getFullYear(),today.getMonth()+1, 0);
}
nissan
Participant
1065 Points
618 Posts
Code for first and last day of month
Jan 31, 2013 09:16 PM|LINK
Can anyone please give me the code for first and last day of the month in jquery or javascript please
I found this for first day but its not working correctly
Rion William...
All-Star
27460 Points
4546 Posts
Re: Code for first and last day of month
Jan 31, 2013 09:44 PM|LINK
To get the last day of the current month in Javascript, you could use this :
For the first day of the current month, use this :
Example
As far as formatting as you have mentioned (using .toString()) you'll have to use something similar to the answers found in this StackOverflow discussion to handle that.
nissan
Participant
1065 Points
618 Posts
Re: Code for first and last day of month
Feb 01, 2013 01:17 PM|LINK
Thanks Rion,
The dates work now. I have a datepicker on inout element whihc is not picking up this date..
Rion William...
All-Star
27460 Points
4546 Posts
Re: Code for first and last day of month
Feb 01, 2013 01:33 PM|LINK
I haven't used KnockOut to bind a DatePicker previously. Are each of your your functions that you have within your observable method returning values, ie :
function getLastDayOfMonth(){ var today = new Date(); return new Date(today.getFullYear(),today.getMonth()+1, 0); }If you are using the jQuery UI DatePicker, based on the information in this Stack Overflow discussion, you should be able to use the minDate and maxDate properties :
<input data-bind="datepicker: myDate, datepickerOptions: { minDate: getFirstDayOfMonth(), maxDate:getLastDayOfMonth() }" />