1--TEST-- 2DateTime/DateTimeImmutable compare handler 3--FILE-- 4<?php 5class MyDateTime extends DateTime 6{ 7 function __construct() 8 { 9 } 10} 11 12$DT = new DateTime("2023-01-16 17:09:08"); 13$DTI = new DateTimeImmutable("2023-01-16 17:09:08"); 14 15$MDT = new MyDateTime(); 16 17var_dump($DT < $DTI); 18 19try { 20 var_dump($DT < $MDT); 21} catch (\DateObjectError $e) { 22 echo $e::class, ': ', $e->getMessage(), "\n"; 23} 24 25try { 26 var_dump($MDT < $DT); 27} catch (\DateObjectError $e) { 28 echo $e::class, ': ', $e->getMessage(), "\n"; 29} 30 31try { 32 var_dump($DTI < $MDT); 33} catch (\DateObjectError $e) { 34 echo $e::class, ': ', $e->getMessage(), "\n"; 35} 36 37try { 38 var_dump($MDT < $DTI); 39} catch (\DateObjectError $e) { 40 echo $e::class, ': ', $e->getMessage(), "\n"; 41} 42?> 43--EXPECT-- 44bool(false) 45DateObjectError: Trying to compare an incomplete DateTime or DateTimeImmutable object 46DateObjectError: Trying to compare an incomplete DateTime or DateTimeImmutable object 47DateObjectError: Trying to compare an incomplete DateTime or DateTimeImmutable object 48DateObjectError: Trying to compare an incomplete DateTime or DateTimeImmutable object 49