Search code examples
datetimesymfony1comparepropel

Comparing DateTime object in symfony (with propel)


I want to compare two DateTime objects in php code. I'm using Symfony 1.4 with Propel.

$article = $obj->getArticle();
if($article->getVisibleFrom() <= new DateTime()) {
     DO_SOMETHING();
}

The problem is that I'm getting string from getVisibleFrom() getter (instead of DateTime object). In database visible_from field is type of DATETIME. I read that with Doctrine I could use function getDateTimeObject('visible_from').


Solution

  • You can change the default behavior at build time by changing build properties: http://www.propelorm.org/reference/buildtime-configuration.html#datetime_settings

    And here is the doc for the temporal getters: http://www.propelorm.org/reference/active-record.html#temporal_columns

    William