CoderZone.org

Category: >> JavaScript >> Check whether a date belongs to a leap year Bookmark and Share

<< lastnext >>

Snippet Name: Check whether a date belongs to a leap year

Description: This snippet will check whether a given date belongs to a leap year.

Comment: (none)

Author: CoderZone
Language: JAVASCRIPT
Highlight Mode: JAVASCRIPT
Last Modified: December 01st, 2010

// Returns true if year is a leap year; otherwise 
// will return false
 
Date.prototype.isLeapYear =
  function(utc) {
    var y = utc ? this.getUTCFullYear() : this.getFullYear();
    return !(y % 4) && (y % 100) || !(y % 400) ? true : false;
};
 
 
There haven't been any comments added for this snippet yet. You may add one if you like.  Add a comment 
© coderzone.org | users online: 3