Right now in knockout js I wrote a function which changes a date field to 21/2/02, this is the function
ko.bindingHandlers.formatDate = {
update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
var value = valueAccessor();
var newValueAccessor = ko.unwrap(value);
var dt = new Date(newValueAccessor);
if (newValueAccessor != null)
$(element).text(dt.toLocaleDateString());
}
};
I want to know if I can change the dates to 2002-02-21.