Date.prototype.setUTCDate()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
setUTCDate()
方法就是根据全球时间设置特定 date 对象的日期。
尝试一下
const event = new Date("August 19, 1975 23:15:30 GMT-3:00");
console.log(event.getUTCDate());
// Expected output: 20
event.setUTCDate(19);
console.log(event.getUTCDate());
// Expected output: 19
语法
dateObj.setUTCDate(dayValue)
参数
dayValue
-
一个 1-31 的整形数字,用来指定日期。
描述
示例
使用 setUTCDate()
js
var theBigDay = new Date();
theBigDay.setUTCDate(20);
规范
Specification |
---|
ECMAScript® 2025 Language Specification # sec-date.prototype.setutcdate |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
setUTCDate |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on 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.