ng2-ui / datetime-picker

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

Need MM/DD/YYYY hh:mm a format time but ... #209

Open egnashko opened 6 years ago

egnashko commented 6 years ago

Need MM/DD/YYYY hh:mm a format time but ...

Hi! I need "MM/DD/YYYY hh:mm am/pm" format time but "date-format" doesn't work it doesn't give any data when event happens, i also tried to make own format but can't understand how to make it, can u help me with it?

Can u give an example with this function:

"// Override Date object formatter
NguiDatetime.formatDate = (date: Date) : string => {
    ..... my own function that returns a string ....
};"

Or if its possible to give me a code in property above, which will return me the needed format, please help. Thank you for attention.

allenhwkim commented 6 years ago

Please include MomentJS,

<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.15.1/moment-with-locales.min.js"></script>

and the format should be date-format="MM/DD/YYYY hh:mm" according to https://momentjs.com/docs/#/parsing/string-format/

egnashko commented 6 years ago

Thank you, it works. But also have one question. When i am choosing time i still have 24 hours, not 12 am and 12 pm, can i change it somewhere? The [show-am-pm]="true" not working, returns error Template parse errors: Can't bind to 'show-am-pm' since it isn't a known property of 'input'.