Help get this topic noticed by sharing it on Twitter, Facebook, or email.

Date Calculation

Hi all,

I'm trying to calculate the number of weeks between the date today and a specific date in the past. I want to run an 8 week cycle in the app.

It seems to work, however, for the below, if I set the date to a couple of days ago, I get week 6, yet if I set it to today, I get week 7. All of this week (Mon-Sun) should be week 7. Am I missing something here?

var startdate = new Date();
startdate.setDate(25); //Recent date of week 1
startdate.setMonth(01);//Feb is 1

var d = new Date();
d.setDate(08); //Couple of days ago

var one_week=1000*60*60*24*7;
var NumberOfWeek = Math.ceil(((d.getTime())-startdate.getTime())/(one_week));//returns the weeks between the two dates

1 person has
this problem