PHPize Online / SQLize Online

Donate Popular


Tags: PHP 5.x PHP 7.x PHP 8.x

date — Format a local time/date.


    string $format,
int|null $timestamp = null
): string
Returns a string formatted according to the given format string using the given integer timestamp or the current time if no timestamp is given. In other words, timestamp is optional and defaults to the value of time().


Format accepted by DateTimeInterface::format().
The optional timestamp parameter is an int Unix timestamp that defaults to the current local time if timestamp is omitted or null. In other words, it defaults to the value of time().

Return Values

Returns a formatted date string. If a non-numeric value is used for timestamp, false is returned and an E_WARNING level error is emitted.

date - New snippets