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 don't need to print the am/pm, I found the following nice and concise:
This is based off @bbrame's answer.
Check out Datejs. Their built in formatters can do this: http://code.google.com/p/datejs/wiki/APIDocumentation#toString
It's a really handy library, especially if you are planning on doing other things with date objects.
Please find the solution below