JavaScript Tutorial.31

ansunny1170·2021년 12월 20일
0
post-thumbnail

JS Get Date Methods

다음 메서드는 날짜 개체에서 정보를 얻는데 사용할 수 있다.

MethodDescription
getFullYear()Get the year as a four digit number (yyyy)
getMonth()Get the month as a number (0-11)
getDate()Get the day as a number (1-31)
getHours()Get the hour (0-23)
getMinutes()Get the minute (0-59)
getSeconds()Get the second (0-59)
getMilliseconds()Get the millisecond (0-999)
getTime()Get the time (milliseconds since January 1, 1970)
getDay()Get the weekday as a number (0-6)
Date.now()Get the time. ECMAScript 5.

The getTime() Method

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

The getFullYear() Method

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

The getMonth() Method

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

JavaScript에서 첫 번째 달(1월)은 0번째 달이므로 12월은 11을 반환한다.

배열과 getMonth()를 사용하여 월을 이름으로 반환시키는 방법이다.

The getDate() Method

getDate() 메서드는 날짜의 날짜를 숫자(1-31)로 반환한다.

The getHours() Method

getHours() 메서드는 날짜의 시간을 숫자(0-23)로 반환한다.

The getMinutes() Method

getMinutes() 메서드는 날짜의 분을 숫자(0-59)로 반환한다.

The getSeconds() Method

getSeconds() 메서드는 날짜의 초를 숫자(0-59)로 반환한다.

The getMilliseconds() Method

getMilliseconds() 메서드는 날짜의 밀리초를 숫자(0-999)로 반환한다.

The getDay() Method

getDay() 메서드는 날짜의 요일을 숫자(0-6)로 반환한다.

JavaScript에서 요일(0)은 '일요일'을 의미하지만, 일부 국가에서는 요일을 '월요일'로 간주한다.

역시 배열과 getDay()를 사용하여 요일을 이름으로 반환할 수 있다.

UTC Date Methods

UTC 날짜 방법은 UTC 날짜(Universal Time Zone 날짜) 작업에 사용된다.

MethodDescription
getUTCDate()Same as getDate(), but returns the UTC date
getUTCDay()Same as getDay(), but returns the UTC day
getUTCFullYear()Same as getFullYear(), but returns the UTC year
getUTCHours()Same as getHours(), but returns the UTC hour
getUTCMilliseconds()Same as getMilliseconds(), but returns the UTC milliseconds
getUTCMinutes()Same as getMinutes(), but returns the UTC minutes
getUTCMonth()Same as getMonth(), but returns the UTC month
getUTCSeconds()Same as getSeconds(), but returns the UTC seconds

Complete JavaScript Date Reference

완전한 Date 참고를 위해 아래 주소를 참조하자
(참조 : https://www.w3schools.com/jsref/jsref_obj_date.asp)

profile
공정 설비 개발/연구원에서 웹 서비스 개발자로 경력 이전하였습니다. Node.js 백엔드 기반 풀스택 개발자를 목표로 하고 있습니다.

0개의 댓글