본문 바로가기
JavaScript

18 - 자바스크립트 - Date (내장객체)

by blancfleur 2021. 9. 12.

1. 자바스크립트 - Date(내장객체)

-date는 윈도우에 있는 내장객체이다. 

    getFullYear() :년도 4 자리
    getMonth() : 월 (0~11) - 0: 1월, 11: 12월
    getDate() : 일
    getDay () : 요일(0:일, 1:월, ...., 6:토)
    
    getHours() :시간
    getMinutes() :분
    getSeconds() :초
    
    getMilliseconds() :밀리초(1/1000 초)
    getTime() :1970년 1월 1일 부터 경과시간(밀리초 기준)



  -Date 객체를 생성하는 방법 4가지
    new Date ();
    new Date(milliseconds);
    new Date(datestring); datestring : "2021/09/10 17:36:10";
    new Date (year, month, date, hours, minutes, seconds, milliseconds);