]> git.andy128k.dev Git - ipf-legacy-orm.git/commitdiff
add formatDate utility
authorAndrey Kutejko <aku@anahoret.com>
Tue, 13 Jan 2015 09:43:37 +0000 (11:43 +0200)
committerAndrey Kutejko <aku@anahoret.com>
Tue, 13 Jan 2015 09:43:37 +0000 (11:43 +0200)
src/adminmodel.php

index a0bc88f4f9ce0678a475a856207bae85f2dd90c8..f656bb7eba83d7e4c1d5d8da95d44bf5c1528411 100644 (file)
@@ -104,12 +104,21 @@ class IPF_Admin_Model extends IPF_Admin_Component
                     ? '<span class="positive">&#x2714;</span>'
                     : '<span class="negative">&#x2718;</span>';
             case 'timestamp':
-                return Text::escape(IPF_Utils::formatDate($value));
+                return Text::escape(self::formatDate($value));
             default:
                 return Text::escape($value);
         }
     }
 
+    protected static function formatDate($str, $format='Y-m-d H:i:s', $tz=null)
+    {
+        if (!$tz)
+            $tz = IPF::get('time_zone');
+        $date = new DateTime($str, new DateTimeZone('UTC'));
+        $date->setTimeZone(new DateTimeZone($tz));
+        return gmdate($format, $date->format('U') + $date->getOffset());
+    }
+
     protected function columnTitle($column)
     {
         $columns = $this->table()->getColumns();