Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1.         foreach ($this->getMetaData()->columns as $column) {
  2.             $columnName = $column->name;
  3.  
  4.             switch ($column->dbType) {
  5.                 case 'date':
  6.                     if (empty($this->$columnName)) {
  7.                         $this->setAttribute($columnName, null);
  8.                     } else {
  9.                         $this->setAttribute($columnName, date('d.m.Y', strtotime($this->$columnName)));
  10.                     }
  11.                 break;
  12.  
  13.                 case 'timestamp without time zone':
  14.                     if (empty($this->$columnName)) {
  15.                         $this->setAttribute($columnName, null);
  16.                     } else {
  17.                         $this->setAttribute($columnName, date('d.m.Y H:i:s', strtotime($this->$columnName)));
  18.                     }
  19.                 break;
  20.             }
  21.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement