时间:2022-07-30 07:45:01 | 来源:网站运营
时间:2022-07-30 07:45:01 来源:网站运营
比如进入信访办的官网,上面的日期显示的是今天是19113年7月1日。怎么回事?关注者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 他用的 是字符串 !!(想起来了,这货该是拷贝 19xx 年的代码) date1 = centry + (today.getYear())
date1 = "19" + "113" // return 19113
即使要用,if (today.getYear() < 2000) centry = 1900;date1 = (centry + today.getYear()); // return 2013
而 为什么 IE 8 能得到 正确的值呢。关键词:政府