Skip to content

Instantly share code, notes, and snippets.

@cebe
Last active February 10, 2017 13:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cebe/42dd6eb0bd26e06a04bcfdaf7d08c891 to your computer and use it in GitHub Desktop.
Save cebe/42dd6eb0bd26e06a04bcfdaf7d08c891 to your computer and use it in GitHub Desktop.
<?php
use yii\behaviors\TimestampBehavior;
public function behaviors()
{
return [
'timestamp' => function() {
$b = new TimeStampBehavior();
$b->attributes = [
ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
];
// ...
return $b;
},
];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment