We will see this display on some websites when using Firefox:
The current time is: January 26, 108
The IE browser displays normally:
The current time is: January 26, 2008
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", but Microsoft has made a change:
When the year of today is greater than or equal to 2000, 1900 is added directly and the returned 200X (instead of 10X)
For example: today’s year is 1999, return 99
Today’s year is 2000. Return 2000
A simple solution is to add a judgment:
year = (year<1900?(1900+year):year);
There is also another method:
Call
through getFullYear getUTCFullYear
var year = today.getFullYear();