返回 ezj。
Date.from(year, month, day[, hour, minute, second[, millisecond]]) 根据指定的年月日、年月日时分秒、年月日时分秒毫创建日期时间。
语法
Date.from(year, month, day[, hour, minute, second[, millisecond]])
参数
- year integer。要创建的年。
- month integer。要创建的月。一月值为 1。
- day integer。要创建的日。
- hour integer。可选。要创建的时。
- minute integer。可选。要创建的分。
- second integer。可选。要创建的秒。
- millisecond integer。可选。要创建的毫秒。
返回值
Date。若不能转换成日期时间,则为 null。
说明
此方法类似于 new Date,但某些情况下比用 new Date 创建日期时间方便。
示例
var dt = Date.from(2010, 1, 1); // 正确
var dt2 = Date.from(2010, 1, 1, 1, 1, 1); // 正确
var dt3 = Date.from(2010, 1, 1, 1, 1, 1, 2); // 正确