setUTCFullYear()
方法根据世界标准时间为一个具体日期设置年份。
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
dateObj.setUTCFullYear(yearValue[, monthValue[, dayValue]])
yearValue
monthValue
dayValue
如果你没有指定具体的monthValue和dayValue,
将会使用 getUTCMonth
和getUTCDate
方法的返回值。
如果你指定的参数超出了期待范围,setUTCFullYear()方法将会根据Date对象,更新其他参数和日期信息。例如,如果你将monthValue设定为15,年份会增加1,月份值则为为3。
setUTCFullYear()
var theBigDay = new Date();
theBigDay.setUTCFullYear(1997);
规范版本 | 规范状态 | 注解 |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | 初始定义。 在 JavaScript 1.3实施。 |
ECMAScript 5.1 (ECMA-262) Date.prototype.setUTCFullYear |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) Date.prototype.setUTCFullYear |
Standard | |
ECMAScript Latest Draft (ECMA-262) Date.prototype.setUTCFullYear |
Draft |
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | Server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setUTCFullYear | Chrome Full support Yes | Edge Full support 12 | Firefox Full support 1 | IE Full support Yes | Opera Full support Yes | Safari Full support Yes | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 4 | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support Yes | nodejs Full support Yes |
相关连接