ui-date icon indicating copy to clipboard operation
ui-date copied to clipboard

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

Open cleon26 opened this issue 10 years ago • 5 comments

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.

cleon26 avatar Mar 24 '15 15:03 cleon26

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

yemaw avatar Apr 05 '15 06:04 yemaw

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'}"

yemaw avatar Apr 05 '15 06:04 yemaw

same problem in one old project

ivan-zakharchuk avatar Mar 10 '16 23:03 ivan-zakharchuk

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.

alexanderchan avatar Mar 10 '16 23:03 alexanderchan

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

ivan-zakharchuk avatar Mar 11 '16 14:03 ivan-zakharchuk