2022-02-04 16:56:06

I'd like to ask how to judge whether this year is a leap year by obtaining the system year .

The main code of the problem is as follows , Help, please Adopt 【 This answer is in the upper right corner 】, thank you ~~ If you have other questions, you can continue to communicate ~

``    var y = new Date().getFullYear();    if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 1))document.write(y+' Year is ruinian ')    else document.write(y+' Year is a normal year ')``

``var y = new Date().getFullYear();if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)    alert(y+' Year is a leap year ');else    alert(y+' Year is a normal year ');``

perhaps

``var y = new Date().getFullYear();if (new Date(y,2,0).getDate()==29)    alert(y+' Year is a leap year ');else    alert(y+' Year is a normal year ');``

If help , Hope to adopt ！ thank you ! Click my answer Top right 【 Adopt 】 Button

You use... To judge leap years if Just judge .

This is similar to the problem of business knowledge , No java The problem of , Refer to Baidu Encyclopedia below

Where there are leap days in the solar calendar （2 month 29 Japan ） A year of , Leap surplus （ When you are over the age of ten . The time difference between the lunar calendar and the year of return ）.
1582 The intercalation rule since ：
Common leap year ： The Gregorian calendar year is 4 Multiple , It's not 100 Multiple of , For leap year （ Such as 2004 year 、2020 Years are leap years ）.
Leap year of the century ： The Gregorian calendar year is a hundred , Must be 400 A leap year is a multiple of （ Such as 1900 Year is not a leap year ,2000 Year is a leap year ）.
1582 Practice before ： A leap in four years ; If A.D A Year of A（ Positive numbers ） Can be 4 to be divisible by , So it's a leap year ; If B Year of B（ Positive numbers ） Divide 4 more than 1, So it's also a leap year .