Last week, I was sorting out a calendar script I wrote before. There was always a problem with the year display under FF, which made me depressed. For example, the following script: prompts "2007" under IE - no problem! But under FF, it prompts "107"?
]
Google it and you understand. FF's getYear returns the value of "current year -1900" (legend has always been done this way), while NB's MS treats Year>=2000 and directly adds back the subtracted 1900. Haha, I admire IE’s fault tolerance and capacity again^_^
The most direct solution is year = (year < 1900) ? (1900 year) : year;
Of course you have to There is no problem in judging the Browser type and then classifying it.
The most reasonable thing is to use getFullYear or getUTCFullYear to call getYear. You can change the corresponding code in the Code box above to see the effect.
<script>
var today = new Date();
alert(today.getYear());
</script>
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