Home  >  Article  >  Web Front-end  >  firefox getyear() getFullYear number problem of getting the year_time and date

firefox getyear() getFullYear number problem of getting the year_time and date

WBOY
WBOYOriginal
2016-05-16 18:57:371101browse

Javascript's getYear() function is intended to obtain the current "year", such as:


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

Execute under IE browser is the correct "2008", but under browsers such as Firefox, it is executed as "108". The reason is that in browsers such as Firefox, getYear returns the value of "the current year minus 1900" (that is, the year base is 1900). Microsoft's IE directly adds 1900 when today's year is greater than or equal to 2000, and returns 200* instead of 10*. So for browsers such as Firefox, you can use the following code:

[Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh it to execute
]
Of course, we can also directly Use the getFullYear() function:
[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute ]
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn