Skip to content

Instantly share code, notes, and snippets.

@monaye
Created August 17, 2012 12:19
Show Gist options
  • Select an option

  • Save monaye/3378396 to your computer and use it in GitHub Desktop.

Select an option

Save monaye/3378396 to your computer and use it in GitHub Desktop.
Yii :: Adding Create date and Update Time Automatically
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
return array(
array('title','length','max'=>255),
array('title, created, modified', 'required'),
array('modified','default',
'value'=>new CDbExpression('NOW()'),
'setOnEmpty'=>false,'on'=>'update'),
array('created,modified','default',
'value'=>new CDbExpression('NOW()'),
'setOnEmpty'=>false,'on'=>'insert')
);
}
@sudipta26889
Copy link
Copy Markdown

How can i use date('Y-m-d H:i:s', time()) instate of new CDbExpression('NOW()').
Because i want to update time of my time zone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment