php8.5
Home/ Manual/ reference / datetime/ The DateTimeImmutable class

The DateTimeImmutable class

Representation of date and time.

Intro

Representation of date and time.

This class behaves the same as DateTime except new objects are returned when modification methods such as DateTime::modify() are called.

Class synopsis

class DateTimeImmutable implements DateTimeInterface { }

Changelog

VersionDescription
8.4.0The class constants are now typed.
7.1.0The DateTimeImmutable constructor now includes the current microseconds in the constructed value. Before this, it would always initialise the microseconds to 0.

Datetimeimmutable

In this section

Source: reference/datetime/datetimeimmutable.xml · from the official PHP manual (php/doc-en)