Reputation: 4854
I am using Angular-UI Bootstrap Datepicker directive for my project. What i want to do is, when i click to button, datepicker value is updating as expected, however, datepicker popup shows the wrong day. I am using dd.MM.yyyy
format. It shows the mm.dd.YYYY
instead of dd.MM.yyyy
. is it a bug or am i missing something?
function appConfig(datepickerConfig, datepickerPopupConfig) {
datepickerConfig.startingDay = 1;
datepickerPopupConfig.datepickerPopup = 'dd.MM.yyyy';
}
Upvotes: 1
Views: 297
Reputation: 2217
The date picker works just fine in my understanding. The problem is that you change the value in your controller with this.date = "01.10.2015"
.
You might consider doing this with this.date = new Date(2015,9,1)
because date is of type date in the background. The directive cares for the transformation of these formats.
EDIT: If you want to stick to your way, you could use a parse function like this (found it here):
function parseDate(input) {
var parts = input.match(/(\d+)/g);
return new Date(parts[2], parts[1]-1, parts[0]);
}
And the call:
this.date = parseDate("01.10.2015")
Here is your updated plunker.
Upvotes: 3