반응형
참조사이트
// 년
console.log (new Date().getFullYear());
// 월
console.log (new Date().getMonth());
console.log ((new Date().getMonth()) < 10 ? '0' + new Date().getMonth():new Date().getMonth());
// 일
console.log (new Date().getDate());
console.log ((new Date().getDate()) < 10 ? '0' + new Date().getDate():new Date().getDate());
// 시
console.log (new Date().getHours());
console.log ((new Date().getHours()) < 10 ? '0' + new Date().getHours():new Date().getHours());
// 분
console.log (new Date().getMinutes());
console.log ((new Date().getMinutes()) < 10 ? '0' + new Date().getMinutes():new Date().getMinutes());
// 초
console.log (new Date().getSeconds());
console.log ((new Date().getSeconds()) < 10 ? '0' + new Date().getSeconds():new Date().getSeconds());
반응형
'자바스크립트' 카테고리의 다른 글
NODEJS, DENO, BUN 설치 (1) | 2024.11.20 |
---|---|
동영상 플레이 썸네일 + 자동 플레이 (0) | 2024.07.18 |
자바스크립트 날짜 비교하기 (1) | 2024.02.27 |
자바스크립트 동적 로딩 (1) | 2022.01.06 |
module.exports 스타일 (0) | 2020.11.16 |