Formatting using format specifiers:
<?php
date_default_timezone_set("Europe/Oslo");
$ts = new DateTime("1979-12-31 09:15");
echo $ts->format("D Y-m-d H:i:s - \I\S\O \W/\Y: W/o");
Output
Mon 1979-12-31 09:15:00 - ISO W/Y: 01/1980
All format modifiers as supported by date() are supported too.
Predefined formats:
<?php
date_default_timezone_set("Europe/Oslo");
$ts = new DateTime("December 22nd, 2005 15:41");
echo $ts->format(DATE_ISO8601), "\n";
echo $ts->format(DateTime::RFC1036), "\n";
echo $ts->format(DATE_RSS);
Output
2005-12-22T15:41:00+0100
Thu, 22 Dec 05 15:41:00 +0100
Thu, 22 Dec 2005 15:41:00 +0100