자바스크립트 날짜.UTC()
예시
날짜와 1970년 1월 1일 사이의 밀리초 수를 가져옵니다.
let ms = Date.UTC(2020, 02, 30);
아래에서 더 많은 "직접 사용해 보기" 예를 살펴보세요.
정의 및 사용
Date.UTC() 메서드는 UTC에 따라 지정된 날짜와 1970년 1월 1일 자정 사이의 밀리초 수를 반환합니다.
노트
UTC(Universal Time Coordinated)는 세계 시간 표준에서 설정한 시간입니다.
UTC 시간은 GMT 시간(그리니치 표준시)과 동일합니다.
브라우저 지원
Date.UTC()
ECMAScript1(ES1) 기능입니다.
ES1(JavaScript 1997)은 모든 브라우저에서 완벽하게 지원됩니다.
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | Yes | Yes | Yes | Yes | Yes |
통사론
Date.UTC(year, month, day, hours, minutes, seconds, millisec)
Date.UTC()는 Date 객체의 정적 메서드입니다.
d.UTC()와 같은 날짜에는 사용할 수 없습니다.
구문은 항상 Date.UTC()입니다.
매개변수 값
Parameter | Description |
---|---|
year | Required. A four-digit value representing the year, negative values are allowed |
month | Required. An integer representing the month
Expected values are 0-11, but other values are allowed:
|
day | Optional. An integer representing the day of month
Expected values are 1-31, but other values are allowed:
If the month has 31 days:
If the month has 30 days:
|
hour | Optional. Default 0. An integer representing the hour.
Expected values are 0-23, but other values are allowed:
|
min | Optional. Default 0. An integer representing the minutes.
Expected values are 0-59, but other values are allowed:
|
sec | Optional. Default 0. An integer representing the seconds
Expected values are 0-59, but other values are allowed:
|
millisec | Optional. Default 0. An integer representing the milliseconds
Expected values are 0-999, but other values are allowed:
|
기술적 세부 사항
반환 값: | 지정된 날짜-시간과 1970년 1월 1일 자정 사이의 밀리초 수를 나타내는 숫자 |
---|---|
자바스크립트 버전: | ECMA 스크립트 1 |
더 많은 예
예시
현지 시간 대신 UTC 시간을 사용하여 날짜 객체 생성:
let d = new Date(Date.UTC(2020, 02, 30));