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 GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
getUTCDate

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见