Skip to content

Instantly share code, notes, and snippets.

@Poxios
Created August 10, 2022 10:30
Embed
What would you like to do?
자바스크립트 오전 오후 뽑아내기
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