Sunday, April 11, 2010

How to get week number for a date in jQuery

This is a useful function, who tell you week in the year for a custom date.
function(d) {
    
 var day = d.getDay();
 if(day == 0) day = 7;
 d.setDate(d.getDate() + (4 - day));
 var year = d.getFullYear();
 var ZBDoCY = Math.floor((d.getTime() - new Date(year, 0, 1, -6)) / 86400000);
 return 1 + Math.floor(ZBDoCY / 7);
}

1 Comments:

At March 14, 2016 at 11:00 PM , Blogger Naveen said...

This comment has been removed by the author.

 

Post a Comment

Subscribe to Post Comments [Atom]

<< Home