Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS ui-date format

So I have :

<input ng-model="date1" ui-date>
<div ng-model="date2" ui-date></div>

It works great. The div calendar 'date2' will follow the change of its previous ui-date input, namely 'date1' the input box.

AngularUI did a great job, when you have multiple input+div calendars existing in one page, imagine a travel agent booking page, 'date4' will group with 'date3' automatically, 'date6' will group with 'date5' automatically ...etc. well done.

However, in my sample code <input ng-model="date1" ui-date> only works in US format with back-slash delimiters 'MM/dd/yyyy'.

My question is, how do I change the default input date format? If I want to have iso-8601 'yyyy-MM-dd' as my input, ui-date doesn't seem to recognise it as a valid input.

I tried ui-date="yyyy-MM-dd" it doesn't seem to have any effects.

like image 343
Tom Avatar asked Nov 11 '12 05:11

Tom


1 Answers

Since this is a wrapper for the datepicker in jQueryUI, you should check the document here

You can set it like this

ui-date="{ dateFormat: 'yy-mm-dd' }"

Here is the plunker

like image 93
maxisam Avatar answered Sep 28 '22 19:09

maxisam