Answer the question
In order to leave comments, you need to log in
Why is TimestampBehavior in Yii2 throwing an error?
// behavior:
'timestamp' => [
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_at',
'updatedAtAttribute' => 'updated_at',
'value' => new Expression('NOW()'),
],
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, 'Stepper motor controllers', '', '', 1, NOW(), NOW( ), 1, 1, 'kontrollery_sagovyh_dvigatelej')
int(11),
return [
TimestampBehavior::className(),
// ...
Answer the question
In order to leave comments, you need to log in
Попробуйте добавить в поведение
'value' => new Expression('UNIX_TIMESTAMP(NOW())'),
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question