코딩/Javascript
Date() 생성자
코딩쪼렙
2021. 7. 25. 11:03
728x90
Date 생성자는 시간의 특정 지점을 나타내는 Date 객체를 플랫폼에 종속되지 않는 형태로 생성합니다.
Date 객체는 1970년 1월 1일 UTC(국제표준시) 자정으로부터 지난 시간을 밀리초로 나타내는 UNIX 타임스탬프를 담습니다.
새로운 Date 객체를 생성하는 방법은 new 연산자를 사용하는 것이 유일합니다.
now = Date()처럼 Date를 직접 호출하면 새로운 Date 객체가 아니라 문자열을 반환합니다.
new Date()
new Date(value)
new Date(dateString)
new Date(year, monthIndex)
new Date(year, monthIndex, day)
new Date(year, monthIndex, day, hours)
new Date(year, monthIndex, day, hours, minutes)
new Date(year, monthIndex, day, hours, minutes, seconds)
new Date(year, monthIndex, day, hours, minutes, seconds, milliseconds)