How to change output format of material 2 date-pic

2020-02-10 09:19发布

I am using angular material 2 Date-Picker component

The only string input it understands is in ISO date format

Ex. "2017-11-13T10:39:28.300Z"

But i want to patch my form control with locale date value

Ex. "11/13/2017, 4:09:46 PM"

So that it output the later format and even expects this format.

How can i do this? Is there a way to not use ISO but custom formats?

Some Thoughts:

Should i write customDateAdaptor?

Update:

https://stackblitz.com/edit/angular-material-moment-adapter-example-bqvm2f

i have tried to implement custom dateAdaptor by extending nativeDateAdaptor

7条回答
三岁会撩人
2楼-- · 2020-02-10 09:51

you can change it's format like this:

 const Date = Date.replace(/-/g, '/')
查看更多
登录 后发表回答