Oihana PHP

yesterday.php

Table of Contents

Functions

yesterday()  : DateTimeImmutable
Returns the start of the day preceding a reference date.

Functions

yesterday()

Returns the start of the day preceding a reference date.

yesterday([DateTimeInterface|null $now = null ]) : DateTimeImmutable

startOfDay( addDays( $now , -1 ) ) — always 00:00:00.000000 on the previous calendar day, regardless of the time of day $now carries. The timezone of the returned value is the one carried by $now.

Parameters
$now : DateTimeInterface|null = null

The reference date. Defaults to the current date/time.

Tags
throws
DateMalformedStringException

Never thrown in practice (the modifier is always well-formed).

example
use function oihana\core\date\yesterday;

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

Marc Alcaraz (ekameleon)

since
1.2.0
Return values
DateTimeImmutable

The start of the day before $now.

On this page

Search results