Created
August 17, 2012 12:19
-
-
Save monaye/3378396 to your computer and use it in GitHub Desktop.
Yii :: Adding Create date and Update Time Automatically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * @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') | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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