我想在php代码中比较两个DateTime对象。我正在使用Symfony 1.4和Propel。
$article = $obj->getArticle();
if($article->getVisibleFrom() <= new DateTime()) {
DO_SOMETHING();
}
问题是我从getVisibleFrom()
getter(而不是DateTime
对象)获取字符串。
在数据库visible_from
字段中,类型为DATETIME
。
我用Doctrine读到了,我可以使用函数getDateTimeObject('visible_from')
。
答案 0 :(得分:0)
您可以通过更改构建属性来更改构建时的默认行为:http://www.propelorm.org/reference/buildtime-configuration.html#datetime_settings
以下是时间吸气者的文档:http://www.propelorm.org/reference/active-record.html#temporal_columns
威廉