Date.prototype.getUTCDate()
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.
getUTCDate()
方法以世界时为标准,返回一个指定的日期对象为一个月中的第几天
尝试一下
const date1 = new Date("August 19, 1975 23:15:30 GMT+11:00");
const date2 = new Date("August 19, 1975 23:15:30 GMT-11:00");
console.log(date1.getUTCDate());
// Expected output: 19
console.log(date2.getUTCDate());
// Expected output: 20
语法
dateObj.getUTCDate()
参数
无
返回值
getUTCDate()
返回一个 1 到 31 的整数值
示例
示例:使用 getUTCDate()
方法
下面的例子是把当前日期的天数部分赋值给变量 day
.
js
var today = new Date();
var day = today.getUTCDate();
规范
Specification |
---|
ECMAScript® 2025 Language Specification # sec-date.prototype.getutcdate |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getUTCDate |
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.