Created
March 11, 2019 10:24
-
-
Save devoltt/2f3c090daaaadab3ef0e1d3940c1b4d0 to your computer and use it in GitHub Desktop.
Add timestamps created_at and updated_at on yii2 mongodb
This file contains 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
/** | |
* Add timestamps on create and update records | |
* | |
* @return array | |
*/ | |
public function behaviors() | |
{ | |
return [ | |
[ | |
'class' => TimestampBehavior::class, | |
'createdAtAttribute' => 'created_at', | |
'updatedAtAttribute' => 'updated_at', | |
'value' => new \MongoDB\BSON\UTCDateTime(), | |
], | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment