function date_weeks_in_year in Date 8
Same name and namespace in other branches
- 5.2 date_api.module \date_weeks_in_year()
- 6.2 date_api.module \date_weeks_in_year()
- 6 date_api.module \date_weeks_in_year()
- 7.3 date_api/date_api.module \date_weeks_in_year()
- 7 date_api/date_api.module \date_weeks_in_year()
- 7.2 date_api/date_api.module \date_weeks_in_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
- date_api/
date_api.module, line 808 - This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.
Code
function date_weeks_in_year($year) {
$date = new DrupalDateTime($year + 1 . '-01-01 12:00:00', 'UTC');
date_modify($date, '-1 day');
return self::calendar_week($date
->format('Y-m-d'));
}