Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 18:57:37
Original
1100 people have browsed it

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 ]
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!