Date.prototype.getUTCFullYear()
Date 实例的 getUTCFullYear() 方法根据世界时间返回该日期的年份。
¥The getUTCFullYear() method of Date instances returns the year for this date according to universal time.
Try it
语法
参数
返回值
描述
¥Description
与 getYear() 不同,getUTCFullYear() 返回的值是绝对数字。对于 1000 年到 9999 年之间的日期,getFullYear() 返回一个四位数字,例如 1995。使用此功能可确保年份符合 2000 年之后的年份。
¥Unlike getYear(), the value returned by getUTCFullYear() is an absolute number. For dates between the years 1000 and 9999, getFullYear() returns a four-digit number, for example, 1995. Use this function to make sure a year is compliant with years after 2000.
示例
使用 getUTCFullYear()
规范
| Specification |
|---|
| ECMAScript Language Specification # sec-date.prototype.getutcfullyear |
浏览器兼容性
BCD tables only load in the browser