angular-ui / ui-date

jQuery UI Datepicker for AngularJS
http://angular-ui.github.io/ui-date/
MIT License
266 stars 207 forks source link

Usage - Why am I unable to use a string date formatted in ISO? #120

Open cleon26 opened 9 years ago

cleon26 commented 9 years ago

My dates are coming back from the server as strings formatted like this: "2014-08-20T00:00:00-04:00"

What is the trick for making this work with the date picker? I've tried several variations of ui-date-format without success. I get different errors about being unable to parse the string.

yemaw commented 9 years ago

Yes, I've the same issue. I've tried many formats and options and still doesn't work.

yemaw commented 9 years ago

Hi @cleon26 , I think we've got the answer. Formatting the date is in ui-date directive, not in ui-date-format. Like this, ui-date="{dateFormat:'yy-mm-dd',changeYear: true, changeMonth: true, yearRange: '1950:-0'}"

ivan-zakharchuk commented 8 years ago

same problem in one old project

alexanderchan commented 8 years ago

I believe it parses these if there is no date format, however it's safest to use a Date in the model. So new Date("2014-08-20T00:00:00-04:00") will work to parse your iso date.

ivan-zakharchuk commented 8 years ago

the problem is that even example

<input ui-date ui-date-format="DD, d MM, yy" ng-model="myDate">

where directive ui-date-format doesn't work, but maybe it is only on angular v1.5, because I didn't test this with previous versions