Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to get angular-ui-bootstrap date picker to accept multiple formats for dates?

Using latest angular-ui-bootstrap and the date picker directive to do my date selections, but what I'd like to know is if it's possible to have the date picker select two different formats for a text box.

<input type="text" 
 class="form-control" 
 ng-model="vm.startDate" 
 uib-datepicker-popup="M/d/yyyy" 
 datepicker-options="vm.dateOptions" 
 close-text="Close" 
 is-open="vm.opened1" 
 placeholder="Start Date" 
 ng-required="false" 
 min-date="vm.minDate" 
 max-date="vm.maxDate" 
 init-date="vm.getCalendarInitDate()"
/>

the uib-datepicker-popup="M/d/yyyy" works fine for dates like 9/5/2015 but what about somebody who puts in 9/5/15? It doesn't work out that.

Ideally, I'd like both of them to be acceptable.

Any ideas?

like image 690
Nick Jacobs Avatar asked Oct 14 '15 18:10

Nick Jacobs


1 Answers

Seems that the issue (at least for days and months) has been fixed with this commit. You can now define a day/month/year-date in format d!.M!.yyyy. It allows an optional leading zero for day and month. See this github-issue for more information.

like image 173
Ursin Brunner Avatar answered Sep 29 '22 16:09

Ursin Brunner