DateTime::__serialize

DateTimeImmutable::__serialize

DateTimeInterface::__serialize

Serialize a DateTime

&reftitle.description; public `array` `DateTime::__serialize` public `array` `DateTimeImmutable::__serialize` public `array` `DateTimeInterface::__serialize`

The __serialize() handler.

&reftitle.parameters; &no.function.parameters;
&reftitle.returnvalues;

The serialized representation of the `DateTime` object.

&reftitle.examples;

### `DateTime::serialize` example

    <?php
    $date = new DateTime('2025-03-27');
    var_dump(serialize($date));
    ?>

&examples.outputs;

    string(114) "O:8:"DateTime":3:{s:4:"date";s:26:"2025-03-27 00:00:00.000000";s:13:"timezone_type";i:3;s:8:"timezone";s:3:"UTC";}"

&reftitle.seealso;

- `DateTime::__unserialize`