Current Week No. PHP Function
if(!function_exists('current_week_no'))
{
function current_week_no()
{
$current_date = date('Y-m-d');
$date_part = explode('-', $current_date);
$date_part[2] = '01';
$start_of_month = implode('-', $date_part);
$day_for_first = date('N', strtotime($start_of_month));
$day_for_month = date('j', strtotime($current_date));
$current_month_current_week = floor(($day_for_first + $day_for_month - 1) / 7) + 1;
$last_month = (date('m')-1);
$week_limit_of_last_month = $last_month*4;
$return = $week_limit_of_last_month+$current_month_current_week;
return $return;
}
}
Last updated: March 19, 2014