date_format()
date_format() — Alias of DateTime::format().
Built-in function of PHP 8.5. The manual lists it as available in PHP 5 >= 5.2.0, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
date_format() is an alias of DateTime::format(): same parameters, same return value.
Signature
date_format(DateTimeInterface $object, string $format): string
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $object | DateTimeInterface | Procedural style only: A DateTime object returned by date_create() |
| $format | string | The format of the outputted date string. See the formatting options below. There are also several predefined date constants that may be used instead, so for example DATE_RSS contains the format string 'D, d M Y H:i:s'. |
Return value
Returns the formatted date string on success.
Example
A runnable snippet:
$date = new DateTimeImmutable('2000-01-01'); echo $date->format('Y-m-d H:i:s');
Output:
2000-01-01 00:00:00
All PHP 8.5 built-in functions
Reference card built from the PHP manual page date_format() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.