I am creating project in yii. I am having Poll table with the fields as-
-pollId
-pollQustion
-isActive
-publishDate
I want to check weather publishdate of poll is not greater than current date.
I am implementing as-
$CurrrentDate=new CDbExpression('NOW()');
if($record->publishDate < $CurrrentDate))
{
some code......
}
But its not executing correctly. Code is executing even if publish date is greater than current date. So how to make this comparison in yii framework. please help me
PHP do not have a date format. When you compare $CurrentDate and $record->publishDate you compare strings. Well, for right compare you need to convert it to Unix’s timestamp