getUTCFullYear 方法 (Date)
使用协调通用时间(UTC)获取年份。
语法
dateObj.getUTCFullYear()
参数
必需的dateObj引用是Date对象。
返回值
返回由四位数字表示的年份。在Date构造函数或setFullYear中指定为两位数字的年份被假定处于20世纪,因此,对于给定的“5/14/12”,getUTCFullYear将返回“1912”。
备注
若要使用当地时间获取年份,请使用getFullYear方法。
示例
下面的示例演示如何使用getUTCFullYear方法。
var date = new Date("1/9/36"); document.write(date.getUTCFullYear()); // Output: 1936
必备条件
在以下文档模式中受支持:怪异模式、Internet Explorer 6标准模式、Internet Explorer 7标准模式、Internet Explorer 8标准模式、Internet Explorer 9标准模式、Internet Explorer 10标准模式、Internet Explorer 11标准模式。应用商店应用(Windows 8和Windows Phone 8.1)中也受支持。请参阅版本信息。
Applies To: Date Object