<?php
var_dump(new DateTimeImmutable() instanceof Jsonserializeable);
var_dump(new DateTime() instanceof JsonSerializeable); // And this works even without it...
// -----------
class Test extends DateTime implements JsonSerializeable {
public function jsonSerialize() {
return "called";
}
}
var_dump(json_encode(new DateTime('2015-05-03')));
bool(false)
bool(false)
Fatal error: Uncaught Error: Interface "JsonSerializeable" not found in /in/r3SoZ:9
Stack trace:
#0 {main}
thrown in /in/r3SoZ on line 9
Process exited with code 255.
Output for 7.4.0 - 7.4.33
bool(false)
bool(false)
Fatal error: Uncaught Error: Interface 'JsonSerializeable' not found in /in/r3SoZ:9
Stack trace:
#0 {main}
thrown in /in/r3SoZ on line 9
Process exited with code 255.