Answer the question
In order to leave comments, you need to log in
Adding your date to timestamp yii2?
Good afternoon.
At the moment, the current date is written in buy_at, stop_at:
return [
'timestamp' => [
'class' => TimestampBehavior::class,
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => [
'buy_at', 'stop_at',
],
],
'value' => new Expression('NOW()'),
],
];
Answer the question
In order to leave comments, you need to log in
if you need to generate your own date for each field, you need to connect the behavior twice, for example:
return [
'timestamp_buy_at' => [
'class' => TimestampBehavior::class,
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => [
'buy_at',
],
],
'value' => new Expression('NOW()'),
],
'timestamp_stop_at' => [
'class' => TimestampBehavior::class,
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => [
'stop_at',
],
],
'value' => new Expression('NOW() + INTERVAL 30 DAY'),
],
];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question