PHP 4+ supplies a method, format that converts a DateTime object into a string with a desired format. According to PHP Manual, this is the object oriented function:
public string DateTime::format ( string $format )
The function date() takes one parameters - a format, which is a string
The format is a string, and uses single characters to define the format:
These characters can be used in various combinations to display times in virtually any format. Here are some examples:
$date = new DateTime('2000-05-26T13:30:20'); /* Friday, May 26, 2000 at 1:30:20 PM */
$date->format("H:i");
/* Returns 13:30 */
$date->format("H i s");
/* Returns 13 30 20 */
$date->format("h:i:s A");
/* Returns 01:30:20 PM */
$date->format("j/m/Y");
/* Returns 26/05/2000 */
$date->format("D, M j 'y - h:i A");
/* Returns Fri, May 26 '00 - 01:30 PM */
The procedural format is similar:
$date->format($format)
date_format($date, $format)