목차
- Date
- getFullYear()
- getMonth()
- getDate()
- getDay()
- getTime()
- getHours()
- getMinutes()
- getSeconds()
- getMilliseconds()
Date
현재 날짜와 시간을 가지는 객체를 리턴
const NOW = new Date(); // 기본형
const NOW = new Date( "2023-04-30 15:20:30.123" ); // 날짜를 지정해서 가져올수 있음
getFullYear()
연도만 가져오는 메소드
console.log( "연도 : " + NOW.getFullYear() );
getMonth()
월을 가져오는 메소드
0 ~ 11을 가져옴
console.log( "월 : " + ( NOW.getMonth() + 1 ) );
getDate()
날짜를 가져오는 메소드
console.log( "일 : " + NOW.getDate() );
getDay()
요일을 가져오는 메소드
일요일 : 0 ~ 토요일 : 6
console.log( "요일 : " + NOW.getDay() );
getTime()
1970 - 01 - 01 기준으로 몇 밀리초가 지났는지 가져옴
console.log( "시간(Linux) : " + NOW.getTime() );
getHours()
시간을 가져오는 메소드
console.log( "시간 : " + NOW.getHours() );
getMinutes()
분을 가져오는 메소드
console.log( "분 : " + NOW.getMinutes() );
getSeconds()
초를 가져오는 메소드
console.log( "초 : " + NOW.getSeconds() );
getMilliseconds()
밀리초를 가져오는 메소드
console.log( "밀리초 : " + NOW.getMilliseconds() );
Github
'JavaScript > JavaScript_ex' 카테고리의 다른 글
DOM_요소 조작하기 (0) | 2023.05.05 |
---|---|
DOM_요소를 선택하는 방법 (0) | 2023.05.05 |
math (0) | 2023.05.05 |
array (0) | 2023.05.03 |
function (1) | 2023.05.02 |