Why TimestampBehavior in Yii2 throws an error?

// behavior:
'timestamp' => [
 'class' => TimestampBehavior::className(),
 'createdAtAttribute' => 'created_at',
 'updatedAtAttribute' => 'updated_at',
 'value' => new Expression('NOW()'),
 ],

Error:
SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'created_at' at row 1
The SQL being executed was: INSERT INTO `category` (`parent_id`, `title`, `mk`, `md`, `visibility`, `created_at`, `updated_at`, `created_id`, `updated_id`, `slug`) VALUES (NULL, 'Controllers stepper motors', ", ", 1, NOW(), NOW(), 1, 1, 'kontrollery_sagovyh_dvigatelej')


Fields for the date
int(11)
,
did everything according to the manual, this one day, plus adds the renewal date if you just write
return [

TimestampBehavior::className(),
 // ...
July 8th 19 at 15:31
2 answers
July 8th 19 at 15:33
Solution
Try to add the behavior

'value' => new Expression('UNIX_TIMESTAMP(NOW())'),
Does not work =( - norene.Nikolaus82 commented on July 8th 19 at 15:36
July 8th 19 at 15:35
Solution
I manual added in model class:

public function behaviors()
{
return [
TimestampBehavior::className(),
];
}

everything works, the 'created_at' and 'updated_at' fields are by default, can be omitted. filled with current time in UTC by default


Created

greggy 10.06.2016

Updated

greggy 01.01.1970 - norene.Nikolaus82 commented on July 8th 19 at 15:38
constantly after upgrade issues - norene.Nikolaus82 commented on July 8th 19 at 15:41
strange. I got the thing working perfectly - norene.Nikolaus82 commented on July 8th 19 at 15:44
Now I came across the documentation for comments to this behavior:

// if the timestamp is UNIX uses the datetime:
// 'value' => new Expression('NOW()'),

and you the expression int(11) tried to use - Brent.Kreig commented on July 8th 19 at 15:47

Find more questions by tags MySQLYii