1.20.x date.inc date_weeks_in_year($year)

The number of calendar weeks in a year.

PHP week functions return the ISO week, not the calendar week.

Parameters

int $year: A year value.

Return value

int: Number of calendar weeks in selected year.

File

includes/date.inc, line 1008
Date API functions and constants.

Code

function date_weeks_in_year($year) {
  $date = new BackdropDateTime(($year + 1) . '-01-01 12:00:00', 'UTC');
  date_modify($date, '-1 day');
  return date_week($date->format('Y-m-d'));
}