문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top