時(shí)間:2022-07-30 07:45:01 | 來(lái)源:網(wǎng)站運(yùn)營(yíng)
時(shí)間:2022-07-30 07:45:01 來(lái)源:網(wǎng)站運(yùn)營(yíng)
比如進(jìn)入信訪辦的官網(wǎng),上面的日期顯示的是今天是19113年7月1日。怎么回事?關(guān)注者80被瀏覽5,967new Date()
The getYear method returns the year minus 1900; thus:
- For years greater than or equal to 2000, the value returned by getYear is 100 or greater. For example, if the year is 2026, getYear returns 126.
- For years between and including 1900 and 1999, the value returned by getYear is between 0 and 99. For example, if the year is 1976, getYear returns 76.
- For years less than 1900, the value returned by getYear is less than 0. For example, if the year is 1800, getYear returns -100.
var enabled = 0; today = new Date(); var day; var date; var centry; if (today.getDay() == 0) day = "星期日" if (today.getDay() == 1) day = "星期一" if (today.getDay() == 2) day = "星期二" if (today.getDay() == 3) day = "星期三" if (today.getDay() == 4) day = "星期四" if (today.getDay() == 5) day = "星期五" if (today.getDay() == 6) day = "星期六" centry = ""; if (today.getYear() < 2000) centry = "19"; date1 = centry + (today.getYear()) + "年" + (today.getMonth() + 1) + "月" + today.getDate() + "日 "; date2 = "" + day; document.write(date1 + date2);
if (today.getYear() < 2000) centry = "19";
注意,centry 他用的 是字符串 ?。。ㄏ肫饋?lái)了,這貨該是拷貝 19xx 年的代碼) date1 = centry + (today.getYear())
date1 = "19" + "113" // return 19113
即使要用,if (today.getYear() < 2000) centry = 1900;date1 = (centry + today.getYear()); // return 2013
而 為什么 IE 8 能得到 正確的值呢。關(guān)鍵詞:政府
客戶&案例
營(yíng)銷資訊
關(guān)于我們
客戶&案例
營(yíng)銷資訊
關(guān)于我們
微信公眾號(hào)
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。