PHP date_format() Function

Example

Returns a new DateTime object and then formats the date:

<?php
$date=date_create("2016-09-25");
echo date_format($date,"Y/m/d H:i:s");
?>

Run Example

Definition and Usage

The date_format() function returns a formatted date based on the specified format.

Syntax

date_format(object,format);
Parameter Description
object Required. Specifies by date_create() Returns the DateTime object.
format Required. Specifies the date format.

Technical Details

Return Value: Returns a formatted date string. If it fails, it returns FALSE.
PHP Version: 5.2+