How many weeks there are in the month with PHP

1

People need to know how to calculate how many weeks there are in a given month with PHP.

What is the best way to do this?

    
asked by anonymous 09.02.2016 / 03:50

1 answer

1

An example on soen

$mes = 2;
$ano = 2016;
$days = cal_days_in_month(CAL_GREGORIAN, $mes, $ano);

$week_day = date("N", mktime(0,0,0,1, $mes, $ano));

$weeks = ceil(($days + $week_day) / 7);

echo $weeks;
    
09.02.2016 / 04:29