PHP 5.4.36 Released

La classe DateTimeInterface

(PHP 5 >= 5.5.0)

Introduction

Synopsis de la classe

DateTimeInterface {
/* Méthodes */
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 )
}

Sommaire

add a note add a note

User Contributed Notes 1 note

up
1
Anonymous
27 days 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