Skip to content

Commit

Permalink
Update controller.php
Browse files Browse the repository at this point in the history
  • Loading branch information
cadyrov authored Mar 11, 2020
1 parent 5cdbf84 commit f445ede
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crud/default/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function actionCreate()
$model->account_id = self::$user->account_id;
<?php
foreach ($tableSchema->columns as $column) {
if ($column->type == 'datetime') {
if ($column->type == 'datetime' || $column->type == 'timestamp') {
echo 'if ($model->'.$column->name.') {';
echo '$model->'.$column->name.' = date("Y-m-d H:i:s", strtotime($model->'.$column->name.'));';
echo '}';
Expand Down Expand Up @@ -276,7 +276,7 @@ public function actionUpdate()
$modelNew->setAttributes(Yii::$app->request->post());
<?php
foreach ($tableSchema->columns as $column) {
if ($column->type == 'datetime') {
if ($column->type == 'datetime' || $column->type == 'timestamp') {
echo '$model->' . $column->name . ' = ($modelNew->'. $column->name . ' date("Y-m-d H:i:s", strtotime($model->'.$column->name.')) ? : null); ';
} else {
echo '$model->' . $column->name . ' = $modelNew->'. $column->name . '; ';
Expand Down

0 comments on commit f445ede

Please sign in to comment.