사용자 도구

사이트 도구


wiki:javascript:javascript_note:js_date_get_methods

문서의 이전 판입니다!


JavaScript Get Date Methods

  • description : JavaScript Get Date Methods
  • author : 오션
  • email : shlim@repia.com
  • lastupdate : 2021-04-13

Ref

JavaScript Get Date Methods

다음의 메소드들은 날짜 오브젝트에서 정보를 가져오기 위해 사용할 수 있습니다.

Method Description
getFullYear() 연도를 4자리 숫자로 가져옵니다.
getMonth() 월을 숫자(0~11)로 가져옵니다.
getDate() 날짜를 숫자(0~31)로 가져옵니다.
getHours() 시간(0~23)을 가져옵니다.
getMinutes() 분(0~59)을 가져옵니다.
getSeconds() 초(0~59)를 가져옵니다.
getMilliseconds() 밀리 초(0~999)를 가져옵니다.
getTime() 1970년 1월 1일 이후의 밀리 초 시간을 가져옵니다.
getDay() 요일을 숫자(0~6)로 가져옵니다.
Date.now() 시간을 가져옵니다. ECMAScript 5


The getTime() Method

getTime() 메서드는 1970 년 1 월 1 일 이후의 밀리 초 수를 반환합니다.

var d = new Date();
document.getElementById("demo").innerHTML = d.getTime();  // 1618280425527

The getFullYear() Method

getFullYear() 메서드는 날짜의 연도를 4 자리 숫자로 반환합니다.

var d = new Date();
document.getElementById("demo").innerHTML = d.getFullYear();   // 2021

The getMonth() Method

getMonth() 메서드는 날짜의 월을 숫자 (0-11)로 반환합니다.

<!DOCTYPE html>
<html>
<body>
    <h2>JavaScript getMonth()</h2>
    <p>The getMonth() Method returns the month of a date as a number from 0 to 11.</p>
    <p>To get the correct month, you must add 1:</p>
    <p id="demo"></p>
    <script>
        var d = new Date();
        document.getElementById("demo").innerHTML = d.getMonth() + 1;   // 4
    </script>
</body>
</html>
/volume1/web/dokuwiki/data/attic/wiki/javascript/javascript_note/js_date_get_methods.1618281782.txt.gz · 마지막으로 수정됨: 2022/03/10 19:52 (바깥 편집)