使用协调通用时间 (UTC) 返回 Date 对象中的月份值。
function getUTCMonth(): Number
若要获取用当地时间表示的月份,请使用 getMonth 方法。
getUTCMonth 方法返回一个介于 0 到 11 之间的整数,该整数指示 Date 对象中的月份值。所返回的整数不是用于指示月份的传统数字。而是要比传统数字小 1。如果一个 Date 对象中存储的值是“Jan 5, 1996 08:47:00.0”,getUTCMonth 将返回 0。
示例下面的示例阐释了 getUTCMonth 方法的用法。
function UTCDateDemo(){ var d, s = "Today's UTC date is: "; d = new Date(); s += (d.getUTCMonth() + 1) + "/"; s += d.getUTCDate() + "/"; s += d.getUTCFullYear(); return(s); }要求
应用于:
参考
getMonth 方法setMonth 方法
setUTCMonth 方法