Oihana PHP

endOfYear.php

Table of Contents

Functions

endOfYear()  : DateTimeImmutable
Returns the last representable instant of the year containing a date.

Functions

endOfYear()

Returns the last representable instant of the year containing a date.

endOfYear(DateTimeInterface $date) : DateTimeImmutable

A new DateTimeImmutable is returned, set to December 31st at 23:59:59.999999 (microseconds included) ; the source date is never modified. The timezone of the returned value is the one carried by $date.

Parameters
$date : DateTimeInterface

The source date.

Tags
example
use function oihana\core\date\endOfYear;

endOfYear( new DateTimeImmutable( '2026-03-15 14:30:45' ) ) ; // 2026-12-31 23:59:59.999999
author

Marc Alcaraz (ekameleon)

since
1.2.0
Return values
DateTimeImmutable

A new immutable date, at the end of the same year.

On this page

Search results