Formatting the date (to mm/dd/yyyy) inside the dependentObservable is exactly what I was wondering how to do. I'll post a little of my code if you can help, Peter Mortensen and/or nEEBz.
<div data-bind="with: technology"> <div class="titleblock"> <label><b>End of Life Date</b></label> <Input type="text" class="ui-datepicker" id="datepicker" data-bind="value: END_OF_LIFE_DATE"/> </div> </div> in ViewModel - technologydetail.js:
var technology = ko.observableArrayobservable(); in Activate:
return dataContext.getTechnologyById(currentTechnologyId, technology); This displays a date that looks like this in the textbox: Wed Jan 29 19:00:00 EST 2014 but I want it to just show: 01/29/2014. I am using this datepicker option - dateFormat: "mm/dd/yy" but it has no effect on the initial value displayed.
I was able to format it using moment and it works nicely for displaying the current database value, but it seems to be breaking the binding back to the observable because it will no longer update on a SAVE.
<Input type="text" class="ui-datepicker" id="datepicker" data-bind="value: moment(END_OF_LIFE_DATE()).format('MM/DD/YYYY')" />