Reputation: 5774
I am trying to set this date as default date in jQuery UI Datepicker 2014-03-13T18:30:00.000Z
I am using JQueryUI datepicker KO binding handler for that. But it is showing wrong JSON date in textbox where the text is bound.
It is showing 10/23/2019
instead of 2014-03-13
..
http://jsfiddle.net/rahulrulez/AkBUv/213/
How to parse it in correct format if there is any?
Upvotes: 0
Views: 1367
Reputation: 3722
This is (indirectly) a duplicate of jQuery UI DatePicker - Change Date Format
To solve your specific example, change your input data-bind expression to
<input data-bind="datepicker: newDate, datepickerOptions: { dateFormat: 'yy-mm-dd' }" />
Your datepicker binding reads the datepickerOptions binding to supplies that object as options to the $.datepicker call.
var options = allBindingsAccessor().datepickerOptions || {};
Be careful when you upgrade to knockout 3.x as the allBindingAccessor has changed. More details from KO's doco -> Creating custom bindings
Upvotes: 1