โ— Shell
clean mode source โ†—

PHP: DateTime::__serialize - Manual

DateTimeImmutable::__serialize

DateTimeInterface::__serialize

(PHP 8 >= 8.2.0)

DateTime::__serialize -- DateTimeImmutable::__serialize -- DateTimeInterface::__serialize โ€” Serialize a DateTime

Description

public function DateTime::__serialize(): array

public function DateTimeImmutable::__serialize(): array

public function DateTimeInterface::__serialize(): array

Parameters

This function has no parameters.

Return Values

The serialized representation of the DateTime object.

Examples

Example #1 DateTime::serialize() example

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

The above example will output:

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";}"

Found A Problem?

There are no user contributed notes for this page.