JS tips and tricks: Difference between revisions
Jump to navigation
Jump to search
Tag: Undo |
(Add categories: Linux, Reference) |
||
| Line 17: | Line 17: | ||
== References == | == References == | ||
<references /> | <references /> | ||
[[Category:Linux]] | |||
[[Category:Reference]] | |||
Revision as of 00:57, 15 July 2026
Display JavaScript datetime in 12 hour AM/PM format[1]
only toLocaleTimeString() may behave differently based on region / location
var time = new Date();
time
Thu May 30 2024 11:56:46 GMT+0900 (한국 표준시)
time.toLocaleString('en-US', { hour: 'numeric', minute: 'numeric', hour12: true })
'11:56 AM'
time.toLocaleString('ko-KR', { hour: 'numeric', minute: 'numeric', hour12: true })
'오전 11:56'
time.toLocaleString('ko-KR')
'2024. 5. 30. 오전 11:56:46'