2
votes

In an older version of symfony (1.2) /w Propel, you were able to just pass a custom date format to the timestampable getters, for example:

$var->getCreatedAt('d.m.Y');

Is there any way to get this to work with symfony 1.4 /w Doctrine - perhaps by somehow overriding the default getter for the timestampable fields (note, I don't want to override the getters for all my model classes, that's kind of a hassle and dirty to me).

I saw that the default date format is set in the Timestampable.php file (Class: Doctrine_Template_Timestampable), but I didn't get much further with it.

1

1 Answers

2
votes

I think it's a feature from Propel wich isn't integrated in Doctrine. Too bad.

With Doctrine, I do it using the DateHelper:

<?php use_helper('Date') ?>

<?php echo format_date(
  $var->getCreatedAt(), 
  "d.m.Y"
) ?>

And if you want to use it inside an action:

sfApplicationConfiguration::getActive()->loadHelpers(array('Date'));

$formattedDate = format_date(
  $var->getCreatedAt(), 
  "d.m.Y"
);