]> git.andy128k.dev Git - ipf.git/commitdiff
extract format date utility
authorAndrey Kutejko <andy128k@gmail.com>
Tue, 25 Feb 2014 19:30:58 +0000 (21:30 +0200)
committerAndrey Kutejko <andy128k@gmail.com>
Tue, 25 Feb 2014 19:30:58 +0000 (21:30 +0200)
ipf/admin/model.php
ipf/utils.php

index ac88a3b064ee62535df66090f660a01f78bcd4ff..5eb1459e85c394e7007c8dcba2f203ea19283b57 100644 (file)
@@ -586,9 +586,7 @@ class IPF_Admin_Model
                             $str = '<img src="'.IPF::get('static_url').'admin/img/icon-no.gif" alt="False" />';
                         break;
                     case 'timestamp':
-                        $date = new DateTime($str, new DateTimeZone('UTC'));
-                        $date->setTimeZone(new DateTimeZone(IPF::get('time_zone')));
-                        $str = gmdate('Y-m-d H:i:s', $date->format('U') + $date->getOffset());
+                        $str = IPF_Utils::formatDate($str);
                         break;
                 }
             }
index e459bde74d0a38d574cfb692da7bc7563cc0af61..b325505542889a9d654c82f8f965bc5656f48c4e 100644 (file)
@@ -106,6 +106,15 @@ class IPF_Utils
         return $string;
     }
 
+    public 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());
+    }
+
     static function dateCompare($date1, $date2=null)
     {
         if (strlen($date1) == 10) {