返回 Date 對象中用本地時間表示的月份值。
dateObj.getMonth()
必選項 dateObj 參數為 Date 對象。
要獲取用全球標準時間 (UTC)表示的月份值,請使用 getUTCMonth 方法。
getMonth 方法返回一個處于 0 到 11 之間的整數,它代表 Date 對象中的月份值。這個整數并不等于按照慣例來表示月份的數字,而是要比按慣例表示的值小 1。假如一個 Date 對象中保存的時間值是 "Jan 5, 1996 08:47:00",那么 getMonth 方法就會返回 0。
下面這個例子說明了 getMonth 方法的用法:
function DateDemo(){ var d, s = "今天日期是: ";d = new Date();s += (d.getMonth() + 1) + "/";s += d.getDate() + "/";s += d.getYear();return(s);}
新聞熱點
疑難解答