\Jawira\TheLostFunctions\year

year - Returns current year.

Description

year(bool $short = false, ?DateTimeInterface $dateTime = null): string

Will return current year as a string. When the first parameter $short is set to true two digit year is returned.

You can also pass a DateTime object as a second argument, the function will return the year of the given object.

Parameters

short
Return a two digits year.
dateTime
A `DateTime` object.

Return value

A year as string.

Example

Following examples were executed in 2021:

use function Jawira\TheLostFunctions\year;

year();     // 2021
year(true); // 21
year(false, new DateTime('2015-01-12')); // 2015