Menu Bar

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday, 25 January 2017

Javascript code to check year is leap year or not

A leap year occurs every four years to help synchronize the calendar year with the solar year, or the length of time it takes the earth to complete its orbit about the sun, which is about 365¼ days
A common year has 365 days and a leap year 366 days, with the extra day designated as February 29.Some leap years are 2016,2020,2024 etc.

Their are 3 ways to identifies that a year is leap year or not :
  • The year must be divisible by 4.
  • The year can also divisible by 400.
  • If year is not divisible by 100 then it's a leap year.

1
2
3
4
5
6
7
8
function isLeapYear(year){
 if ((year % 400 == 0) || ((year % 4 == 0) && (year % 100 != 0))) {
  return true;
 } 
 else{
  return false;
 }
}


     
Blog Author - Pushkar Khosla,
Software Developer by Profession with 3.0 Yrs of Experience , through this blog i'am sharing my industrial Java Knowledge to entire world. For any question or query any one can comment below or mail me at pushkar.itsitm52@gmail.com.

This blog is all about to learn Core Java ,Interview Programs and Coding tricks to polish your Java Knowledge. If you like the content of this blog please share this with your friends.



Share this Blog with yours Friends !!

No comments:

Post a Comment