Angular material introduced a new date picker component found here.
I want the date returned by this component to be in the format yyy-mm-dd but I am not su
To also address the problem pointed out by kazuar:
Unfortunately it doesn't work if the date is typed from the keyboard
you should define the parseDate method as well. From the docs:
$mdDateLocaleProvider.parseDate = function(dateString) {
var m = moment(dateString, 'L', true);
return m.isValid() ? m.toDate() : new Date(NaN);
};
For a full example, I have in my app (using moment):
$mdDateLocaleProvider.formatDate = function(date) {
return moment(date).format('DD/MM/YYYY');
};
$mdDateLocaleProvider.parseDate = function(dateString) {
var m = moment(dateString, 'DD/MM/YYYY', true);
return m.isValid() ? m.toDate() : new Date(NaN);
};
Regards