How can i get the week number of month using javascript / jquery?
For ex.:
First Week: 5th July, 2010. / Week Number = First monday
function getWeekOfMonth(date) {
var nth = 0; // returning variable.
var timestamp = date.getTime(); // get UTC timestamp of date.
var month = date.getMonth(); // get current month.
var m = month; // save temp value of month.
while( m == month ) { // check if m equals our date's month.
nth++; // increment our week count.
// update m to reflect previous week (previous to last value of m).
m = new Date(timestamp - nth * 604800000).getMonth();
}
return nth;
}