DateTime::getTimestamp
PHP 5 >= 5.3.0, PHP 7, PHP 8
DateTime::getTimestamp - Gets the Unix timestamp
Manual
DateTime::getTimestamp(
): public int
public intDateTimeImmutable::getTimestamp
Parameters
This function has no parameters.
Return Values
Returns the Unix timestamp representing the date.
Exceptions and Errors
If the timestamp cannot be represented as int, a ValueError is thrown. Prior to PHP 8.0.0, false was returned in this case. Still, the timestamp can be retrieved as string by using DateTimeInterface::format with the U format.
Changelog
Version | Description |
8.0.0 | These functions no longer return false on failure. |