Symfony 1.4 format date doctrine object

To format a date from a doctrine object, you can use this code, quick and easy.

$demande->getDateTimeObject('date_creation')->format('d/m/Y');

Sometimes, this first solution return current date even if the doctrine record is null.
You then have to use this other solution

use_helper('Date');
format_date($demande->getDateCreation(), 'dd-MM-yyyy');

You can found format rules here

Leave a Reply