(PHP 5 >= 5.5.0, PHP 7)
DateTimeInterface is meant so that both DateTime and DateTimeImmutable can be type hinted for. It is not possible to implement this interface with userland classes.
public diff ( DateTimeInterface $targetObject [, bool $absolute = false ] ) : DateInterval|false
public format ( string $format ) : string
publicgetOffset ( ) : int
public getTimestamp ( ) : int
public getTimezone ( ) : DateTimeZone|false
public __wakeup ( ) : void}
DateTimeInterface::ATOMDATE_ATOM
DATE_COOKIE
DateTimeInterface::ISO8601DATE_ISO8601
Note: This format is not compatible with ISO-8601, but is left this way for backward compatibility reasons. Use
DateTime::ATOMorDATE_ATOMfor compatibility with ISO-8601 instead.
DateTimeInterface::RFC822DATE_RFC822
DateTimeInterface::RFC850DATE_RFC850
DateTimeInterface::RFC1036DATE_RFC1036
DateTimeInterface::RFC1123DATE_RFC1123
DateTimeInterface::RFC7231DATE_RFC7231
DateTimeInterface::RFC2822DATE_RFC2822
DateTimeInterface::RFC3339DATE_RFC3339
DATE_ATOM (since PHP 5.1.3) DateTimeInterface::RFC3339_EXTENDEDDATE_RFC3339_EXTENDED
DateTimeInterface::RSSDATE_RSS
DateTimeInterface::W3CDATE_W3C
| Version | Description |
|---|---|
| 7.2.0 | The class constants of DateTime are now defined on DateTimeInterface. |
| 5.5.8 | Trying to implement DateTimeInterface raises a fatal error now. Formerly implementing the interface didn't raise an error, but the behavior was erroneous. |
© 1997–2020 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/class.datetimeinterface.php