Hi,
I need to INSERT the difference in two separate timestamps.
The Model Controller has:
public function actionCreate()
{
...
// added to insert start time into _form
$model->startTime=date('Y-m-d H:i:s', strtotime('-7 Hours'));
...
}
and the Model has:
// added to insert end time upon record INSERT
public function behaviors()
{
return array(
'CTimestampBehavior' => array(
'class' => 'zii.behaviors.CTimestampBehavior',
'createAttribute' => 'endTime',
'updateAttribute' => NULL,
)
);
}
I have another attribute “duration” looking to receive the difference between these two timestamps in ‘H:i:s’. All I can find in the MySQL docs is how to do this after the record has been created. I looked through the Yii Class references, but couldn’t find anything that will do the math on the fly as the last thing before the record INSERT. Maybe I’m overlooking something. Can anyone help with this one?