DateTime
DateTime and DateTimeImmutable is a class for the representation of date and time. It has two variants: DateTimeImmutable cannot be modified after creation, while DateTime can.
Both classes comes with the DateTimeInterface, for typing purposes.
DateTime objects may be created with the constructor, and with several specific methods, such as createFromInterface, createFromFormat or createFromImmutable.
<?php
$date = new DateTimeImmutable('2024-02-24 11:45 America/Montreal');
$mutable = DateTime::createFromInterface($date);
$date = new DateTime('2014-06-20 11:45 Europe/Amsterdam');
?>
See Also
Related
- Dates
- Calendar
- DateInterval
- Days Are Not 86400 Seconds
- Micro-second
- Clock
- Datetime Trap
- DateTimeInterface