PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular

date

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

date — Format a local time/date.

Description

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().

Parameters

format
Format accepted by DateTimeInterface::format().
timestamp
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