A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear below:

Date.prototype.getUTCFullYear() - JavaScript | MDN

Date.prototype.getUTCFullYear()

Baseline Widely available

getUTCFullYear() 以世界时为标准,返回一个指定的日期对象的年份。

尝试一下
const date1 = new Date("December 31, 1975, 23:15:30 GMT+11:00");
const date2 = new Date("December 31, 1975, 23:15:30 GMT-11:00");

console.log(date1.getUTCFullYear());
// Expected output: 1975

console.log(date2.getUTCFullYear());
// Expected output: 1976
语法 参数

无。

返回值

getUTCFullYear() 返回一个绝对数值,符合 Year-2000 标准,例如 1995。

示例 示例:使用 getUTCFullYear() 方法

下面的例子是把当前年份的四位数值复制给变量 year。

var today = new Date();
var year = today.getUTCFullYear();
规范 浏览器兼容性 参见

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4