setUTCMonth()方法根据通用的时间来设置一个准确的月份
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.setUTCMonth(monthValue[, dayValue])
monthValue
dayValue
这个数值是从1970年1月1号 00:00:00到当前时间的毫秒数(国际通用时间)
如果你没有明确书写dayValue
这个参数,那么就会从getUTCDate()
方法返回对应的数值.
如果你写了一个超过在规定的范围内的参数. setUTCMonth()就会试图相应的更新时间信息在Data对象中。例如,如果你用15作为
monthValue的值,那么年份就会加1,并且月份会变成3.(15=12+3)
setUTCMonth()
var theBigDay = new Date();
theBigDay.setUTCMonth(11);
规范 | 状态 | 注释 |
---|---|---|
ECMAScript 1st Edition (ECMA-262) | Standard | 最初定义并使用在javascript 1.3版本中 |
ECMAScript 5.1 (ECMA-262) Date.prototype.setUTCMonth |
Standard | |
ECMAScript 2015 (6th Edition, ECMA-262) Date.prototype.setUTCMonth |
Standard | |
ECMAScript Latest Draft (ECMA-262) Date.prototype.setUTCMonth |
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 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setUTCMonth | 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 |