返回 Date 對象中用本地時間表示的年份值。
dateObj.getFullYear()
必選項 dateObj 參數(shù)為 Date 對象。
要獲取用全球標準時間 (UTC)表示的年份值,請使用 getUTCFullYear 方法。
getFullYear 方法以絕對數(shù)字的形式返回年份值。例如,1976 年的返回值就是 1976。這樣可以避免出現(xiàn) 2000 年問題,從而不會將 2000 年1月1日以后的日期與 1900 年1月1日以后的日期混淆起來。
下面這個例子說明了 GetFullYear 方法的用法。
function DateDemo(){ var d, s = "今天UTC日期是: ";d = new Date();s += (d.getMonth() + 1) + "/";s += d.getDate() + "/";s += d.getFullYear();return(s);}
新聞熱點
疑難解答