Question: When I try to output a DateTime object, it is literally printing the format, e.g.

```
Y-m-d H:i:s

```

**Code**

```
$db = new PDO('mysql:host=localhost;dbname=xxx;charset=utf8', 'xxx', 'xxx');
$dbTime = new DateTime(current($db->query('SELECT NOW()')->fetchAll(PDO::FETCH_COLUMN, 0)));
$myTime = new DateTime();
$diff = $myTime->diff($dbTime);
echo $diff->format('Y-m-d H:i:s');

```

From reading other questions and examples this should work so I'm confused why it's not.

Answer: 
The `DateTime::diff` method returns a `DateInterval` object. Your getting unexpected results because you are calling format on a `DateInterval` object which is different to the implementation on the `DateTime` object. see <http://php.net/manual/en/dateinterval.format.php> for more info on how to use it.
The output from [DateTime::diff()](http://www.php.net/manual/en/datetime.diff.php) is a DateInterval object, which has rather different [formatting](http://www.php.net/manual/en/dateinterval.format.php) Meanings.... in particular read about the overflow. Note also the use of % symbols to force format characters, otherwise they're treated as string characters