Oihana PHP

startOfMonth.php

Table of Contents

Functions

startOfMonth()  : DateTimeImmutable
Returns the first representable instant of the month containing a date.

Functions

startOfMonth()

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

startOfMonth(DateTimeInterface $date) : DateTimeImmutable

A new DateTimeImmutable is returned, set to the 1st of the month 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\startOfMonth;

startOfMonth( new DateTimeImmutable( '2026-03-15 14:30:45' ) ) ; // 2026-03-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 month.

On this page

Search results