hi how to find no of weeks and each mondays date between 2 dates. for ex 10-07-2009 to today .
Note :consider leap year and other date related constrains also.
hi how to find no of weeks and each mondays date between 2 dates. for ex 10-07-2009 to today .
Note :consider leap year and other date related constrains also.
echo datediff('ww', '9 July 2003', '4 March 2004', false);
Find the function on the site below: http://www.addedbytes.com/code/php-datediff-function/
$diff = strtotime($datefrom, 0) - strtotime($dateto, 0);
echo floor($diff / 604800);
The following function computes the "spoken weeks" between two timestamps (i.e. monday is next week if you are on saturday).
function days_between($datefrom,$dateto){
$fromday_start = mktime(0,0,0,date("m",$datefrom),date("d",$datefrom),date("Y",$datefrom));
$diff = $dateto - $datefrom;
$days = intval( $diff / 86400 ); // 86400 / day
if( ($datefrom - $fromday_start) + ($diff % 86400) > 86400 )
$days++;
return $days;
}
function weeks_between($datefrom, $dateto)
{
$day_of_week = date("w", $datefrom);
$fromweek_start = $datefrom - ($day_of_week * 86400) - ($datefrom % 86400);
$diff_days = days_between($datefrom, $dateto);
$diff_weeks = intval($diff_days / 7);
$seconds_left = ($diff_days % 7) * 86400;
if( ($datefrom - $fromweek_start) + $seconds_left > 604800 )
$diff_weeks ++;
return $diff_weeks;
}