ng2-ui / datetime-picker

Angular2 DateTime Picker
https://ng2-ui.github.io/#/datetime-picker
MIT License
121 stars 62 forks source link

Separate displayed date format from returned value #86

Closed themastersoda closed 7 years ago

themastersoda commented 7 years ago

Hi, im looking for a way to display date string inside the input in one format, but set model value to a different one. It seems, that now both use the same function to parse date into string. Would it be possible to customize both of those separately?

allenhwkim commented 7 years ago

As you see here, https://github.com/ng2-ui/ng2-datetime-picker/blob/master/src/datetime-picker.directive.ts#L206, the element has its dateValue, and the value you see is toString() of model value. model value is not always a string either. If you want to access date please use dateValue

allenhwkim commented 7 years ago

Please refer to this screenshot.

image

https://plnkr.co/edit/ApJNv9?p=preview