Want to get rid of Google Ads, click here.
+ Reply to Thread
Results 1 to 3 of 3

Thread: Bissextile Year in javascript

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    9

    Default Bissextile Year in javascript

    Hello, I would like to know if a year is a bissextile year or not.
    Have you an idea, because i would want to do a modulo to know if year is a divisible by 4 .

    Thanks a lot

  2. #2
    Senior Member mateuszk's Avatar
    Join Date
    Nov 2006
    Posts
    302

    Default

    Hi there,

    according to wikipedia (see here)
    following should do the trick just fine:

    Code:
    var d=new Date().getFullYear(); 
    var leap=false;
    if(d%4==0 && d%100!=0 || d%400==0) leap=true;
    Last edited by mateuszk; 2010-09-10 at 21:06. Reason: fid509 corrected my error. Thx!

  3. #3
    Senior Member fid509's Avatar
    Join Date
    Feb 2002
    Location
    Brussels
    Posts
    381

    Default

    The code must be
    if(d%4==0 && d%100!=0 || d%400==0) leap=true;

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts