Ion-datetime problem when using moment

I’m trying to use the ion-datetime with momentjs, as I use momentjs to show dates in the app currently.
And my problem is that I’m trying to use momentjs to find the date format. I get the date format by doing this:


I could mention as well that I’m using reactive forms and setting the default values when creating the form controller.

So here is the problem: If I have the momentjs in US locale I get “MMM D, YYYY” and ion-datetime will display that when I give it a default value. But if i use Swedish locale I get “D MMM YYYY” and if I give a default value with the same format (e.g 21 Okt 2019) then it will not show that value. Does anyone know why that is?

Also a bonus question, is it possible to change the output value to be something more ISO-8601 format?

Thanks in advance,

EDIT: Changed from ion-datepicker => ion-datetime

I had this problem with time as well. And after some debugging I realized that it’s not good to send partial date into the ion-datetime component. So when using it always send in the full date and time to make it work the best. That solved most of my problems.

1 Like