The DateTimeInterface interface

(PHP 5 >= 5.5.0)


Class synopsis

DateTimeInterface {
/* Methods */
public DateInterval diff ( DateTimeInterface $datetime2 [, bool $absolute = false ] )
public string format ( string $format )
public int getOffset ( void )
public int getTimestamp ( void )
public DateTimeZone getTimezone ( void )
public __wakeup ( void )

Table of Contents

add a note add a note

User Contributed Notes 1 note

5 months ago
It should be noted that you cannot implement this interface yourself, you'll get a fatal error (apparently by design). Instead, this interface is (currently) only useful for type checking or type hinting to allow either DateTime or DateTimeImmutable.

function someFunction(DateTimeInterface $date){
    //$date could be either DateTime or DateTimeImmutable
To Top