getMonth

HTML/CSS/JS

[JS] 현재 시간 출력, if문 오전 오후 구분하기 (date(),getMonth(),getHours(),if,else)

ㄱ. 현재시간 출력하기 // 현재시간 구하기 let alpha = new Date(); let year = alpha.getFullYear(); let month = alpha.getMonth() + 1; let day = alpha.getDay(); let hours = alpha.getHours(); let minutes = alpha.getMinutes(); let seconds = alpha.getSeconds(); alert(alpha) getMonth() : 반환값이 0~11이기 때문에 뒤에 + 1을 해야 함. ㄴ. if문으로 오전 오후 출력하기 // if 문으로 오전 오후 구하기 let date = new Date(); let hours = date.getHours(); if(hours

DEV장화
'getMonth' 태그의 글 목록