\Jawira\TheLostFunctions\year_range

year_range - Creates a string containing a range of years.

Description

year_range(int $startYear): string

Will return a range if $startYear is greater than current year, otherwise only current year is returned.

This function is useful for website's footers, this is where year ranges are commonly displayed.

Parameters

startYear
Initial year from the range.

Return value

A string containing a range. En dash is used.

Example

Following examples were executed in 2021:

use function Jawira\TheLostFunctions\year_range;

year_range(2013); // 2013–2021
year_range(2020); // 2020–2021
year_range(2021); // 2021
year_range(2025); // 2025