Compatibility issues of JavaScript getyear year function between IE and Firefox in different browsers
Let’s give an example first
You will see such a prompt when using Firefox on some websites
The current time is 106 years August 8th
If you use IE browser, it will display normally August 8th, 2006
The reason is the compatibility issue of javascript
var today = new date ();
var year = today.getYear();
In Firefox, getYear returns the value of "current year-1900" (this was the case before)
And Microsoft is very NB. Made a change:
When today's year is greater than or equal to 2000, 1900 is added directly to the returned 200X (instead of 10X)
For example: today's year is 1999, 99 is returned
Today's year is 2000, 2000 is returned
A simple solution to javascript getyear is to add a judgment:
year = (year
There is also another method
through getFullYear getUTCFullYear to call
var year = today.getFullYear();