(PHP 5 >= 5.2.0)
DateTime::format — Returns date formatted according to given format
Object oriented style
Procedural style
Returns date formatted according to given format.
Procedural style only: A DateTime object returned by date_create()
Format accepted by date().
Returns the formatted date string on success or FALSE on failure.
Example #1 DateTime::format() example
Object oriented style
<?php
$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');
?>
Procedural style
<?php
$date = date_create('2000-01-01');
echo date_format($date, 'Y-m-d H:i:s');
?>
The above example will output:
2000-01-01 00:00:00
This method does not use locales. All output is in English.