JavaScript Date.UTC() 函數
UTC函數語法
Date
.
UTC
(
year
,
month
,
day
)
;
Date
.
UTC
(
year
,
month
,
day
,
hours
)
;
Date
.
UTC
(
year
,
month
,
day
,
hours
,
minutes
)
;
Date
.
UTC
(
year
,
month
,
day
,
hours
,
minutes
,
seconds
)
;
Date
.
UTC
(
year
,
month
,
day
,
hours
,
minutes
,
seconds
,
microseconds
)
;
UTC函數參數
- year - 作爲date對象的年份,爲4位年份值
- month - 0-11之間的整數,做爲date對象的月份
- day - 1-31之間的整數,做爲date對象的天數
- hours - 0(午夜24點)-23之間的整數,做爲date對象的小時數
- minutes - 0-59之間的整數,做爲date對象的分鐘數
- seconds - 0-59之間的整數,做爲date對象的秒數
- microseconds - 0-999之間的整數,做爲date對象的毫秒數
UTC函數返回值
- 返回date對象距1970年1月1日午夜之間的毫秒數(時間戳)
UTC說明
- 此函數爲靜態函數,應該直接調用
- 從UTC方法和Date對象的構造函數都可以獲取一個日誌,它們之間的差別在於: UTC方法假定是UTC,Date對象的構造函數假定是本地時間。
UTC函數示例
document
.
write
(
Date
.
UTC
(
1980
,
12
,
17
)
)
;
- 返回date對象距1970年1月1日午夜之間的毫秒數(時間戳)