Created
August 10, 2022 10:30
-
-
Save Poxios/7ba5a96e3e0110959a98efe46d9168ad to your computer and use it in GitHub Desktop.
자바스크립트 오전 오후 뽑아내기
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getAMPMTimeFromDate = (date: Date) => { | |
let hours = date.getHours(); | |
let minutes = date.getMinutes() as any; | |
let ampm = hours >= 12 ? '오후' : '오전'; | |
hours = hours % 12; | |
hours = hours ? hours : 12; | |
minutes = minutes.toString().padStart(2, '0'); | |
let strTime = ampm + ' ' + hours + ':' + minutes; | |
return strTime; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment