How do you display a JavaScript datetime object in the 12 hour format (AM/PM)?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
If you just want to show the hours then..
Output : 7 AM
If you wish to show the minutes as well then...
Output : 7:23 AM
My suggestion is use moment js for date and time operation.
https://momentjs.com/docs/#/displaying/format/
You can also consider using something like date.js:
I fount it's here it working fine.
and plunker example here
Short RegExp for en-US:
Or just simply do the following code: