Leap Year Check

By vaseline28 on Nov 11, 2009

Just a simple script which uses maths to detect whether or not a year is a leap year or not. If the year inputted is then "true" will be returned, if not "false".

To use the script just use




This function can of course be used within any other function e.g.


Remember to put within !!

function leapYear()
    var date = new Date();
        date.setFullYear((arguments.length > 0) ? arguments[0] : date.getFullYear());

    var divNumber = ((date.getFullYear() + '').slice(-2) == "00") ? 400 : 4;

    return (date.getFullYear() / divNumber == Math.round(date.getFullYear() / divNumber)) ? true : false;


Sign in to comment.
Korvin   -  Mar 04, 2010
function leapCheck(y){y-=2008;if (y < 0){y*=-1;}if((y % 4) == 0){return true;}return false;}

that actually works how you want it to...

MagicRevealer09   -  Feb 14, 2010

Didn't work :S

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.