JavaScript Date.getWeek()?

QuestionsJavaScript Date.getWeek()?
sethbeckerman5 Staff asked 14 years ago

I'm looking for a tested solid solution for getting current week of the year for specified date. All I can find are the ones that doesn't take in account leap years or just plain wrong. Does anyone have this type of stuff?

Or even better a function that says how many weeks does month occupy. It is usually 5, but can be 4 (feb) or 6 (1st is sunday and month has 30-31 days in it)

=================
UPDATE:

Still not sure about getting week #, but since I figured out it won't solve my problem with calculating how many weeks month occupy, I abandoned it.

Here's a function to find out how many weeks exactly month occupy on the calendar:


View on Stack Overflow