Oihana PHP

startOfYear.php

Table of Contents

Functions

startOfYear()  : DateTimeImmutable
Returns the first representable instant of the year containing a date.

Functions

startOfYear()

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

startOfYear(DateTimeInterface $date) : DateTimeImmutable

A new DateTimeImmutable is returned, set to January 1st at 00:00:00.000000 ; 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\startOfYear;

startOfYear( new DateTimeImmutable( '2026-03-15 14:30:45' ) ) ; // 2026-01-01 00:00:00.000000
author

Marc Alcaraz (ekameleon)

since
1.2.0
Return values
DateTimeImmutable

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

On this page

Search results