Search Results
Returns new DateTimeImmutable instance encapsulating the given DateTime object
Feb 17, 2021 · The DateTimeImmutable::createFromMutable () function is an inbuilt function in PHP which is used to return the new DateTimeImmutable object encapsulating the given DateTime object.
Once created, a DateTimeImmutable object cannot be modified. This is great as immutable state should be favored over mutable state. Ever since its introduction, the DateTimeImmutable provides the createFromMutable () method to create a DateTimeImmutable object based on an existing DateTime object:
The mutable DateTime object that you want to convert to an immutable version. This object is not modified, but instead a new DateTimeImmutable object is created containing the same date time and timezone information.
The immutable DateTimeImmutable object that needs to be converted to a mutable version. This object is not modified, but instead a new DateTime instance is created containing the same date, time, and timezone information.
The createFromImmutable method creates a mutable DateTime object from an immutable DateTimeImmutable object. Let's explore its operation with examples.
DateTimeImmutable::createFromMutable — Returns new DateTimeImmutable instance encapsulating the given DateTime object DateTimeImmutable::getLastErrors — Returns the warnings and errors
