- json_encode: documentation ( source)
<?php
class SerialDateTime extends DateTime implements JsonSerializable{
public function jsonSerialize(){
return $this->getTimestamp();
}
}
$x = SerialDateTime::createFromFormat('m', 4);
$y = new SerialDateTime;
echo json_encode([$x,$y]);