|
DateTime::__serializeDateTimeImmutable::__serializeDateTimeInterface::__serializeSerialize a DateTime Description
public array DateTime::__serialize()
public array DateTimeImmutable::__serialize()
public array DateTimeInterface::__serialize()
The __serialize() handler. ParametersThis function has no parameters. Return ValuesThe serialized representation of the DateTime object. ExamplesExample #1 DateTime::__serialize example The above example will output:
string(171) "O:23:"CustomDateTimeImmutable":4:{s:4:"date";s:25:"2025-03-27T00:00:00+00:00";s:9:"timestamp";i:1743033600;s:8:"timezone";s:3:"UTC";s:2:"to";s:21:"Drink a cup of coffee";}"
NotesWarning
An Error is thrown when attempting to unserialize a custom DateTime object if __serialize() is defined but __unserialize() is missing. See Also
|