Leap Year Check In Javascript


/ Published in: JavaScript
Save to your folder(s)

date object return date of next month if day parameter overflows


Copy this code and paste it in your HTML
  1. var month = {LastDay : function(Year,Month){ return 32 - new Date(Year,Month,32).getDate();}}
  2. var Year = {IsLeap: function(Year){ return 29 == month.LastDay(Year,1)}};
  3. Year.IsLeap(2000); // returns true
  4. Year.IsLeap(2000); // returns false

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.