method getMonthWeek documentation in bbn\Date
Gets the month's week of the given date.
function(string $date, string $firstweekday = 'monday')
{
$cut = substr($date, 0, 8);
$daylen = 86400;
$timestamp = strtotime($date);
$first = strtotime($cut . "00");
$elapsed = ($timestamp - $first) / $daylen;
$weeks = 1;
for ( $i = 1; $i <= $elapsed; $i++ ){
$dayfind = $cut . (strlen($i) < 2 ? '0' . $i : $i);
$daytimestamp = strtotime($dayfind);
$day = strtolower(date("l", $daytimestamp));
if ( $day === strtolower($firstweekday) ){
$weeks++;
}
}
return $weeks;
}
Gets the month's week of the given date. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions