Calculate weeks given 2 dates

Calculate weeks given 2 dates



In the image below I show 2 JQuery UI datepicker which I implemented, now I need to calculate the number of weeks between the 2 dates picked and place them in that form.

I tried using this in one of the datepickers (special attention on bold text)
  1. $('#dateF').datepicker({
                dateFormat: 'dd-mm-yy',
                yearRange: '-2:+2',
                changeMonth: true,
                changeYear: true,
                onSelect: function(date, inst) {
                    var week = $.datepicker.iso8601Week(new Date(date));
                    alert(week);


                }





So I could calculate the start and end week and then subtract them. But the way in which I'm getting the weeks is giving some crazy results that dont make any sense. I dont know what I'm doing wrong if anyone could help me out or give some workaround I'd be very thankful.