Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Date.isleap

DZone's Guide to

Date.isleap

·
Free Resource

Date.isleap = function(year){
 return ((year % 400) == 0) ? 1 :
        ((year % 100) == 0) ? 0 :
        ((year % 4)   == 0) ? 1 :
         0;
}
Date.prototype.isleap = function(){
    return Date.isleap(this.getFullYear())
}
// isleap current year
new Date().isleap()
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}