fixed timezone when using the date filter with a UNIX timestamp (it now uses the...
authorFabien Potencier <fabien.potencier@gmail.com>
Sat, 28 May 2011 14:36:42 +0000 (16:36 +0200)
committerFabien Potencier <fabien.potencier@gmail.com>
Sat, 28 May 2011 14:36:42 +0000 (16:36 +0200)
lib/Twig/Extension/Core.php

index 61429d8..96b9d42 100644 (file)
@@ -203,7 +203,12 @@ class Twig_Extension_Core extends Twig_Extension
 function twig_date_format_filter($date, $format = 'F j, Y H:i')
 {
     if (!$date instanceof DateTime) {
-        $date = new DateTime((ctype_digit((string) $date) ? '@' : '').$date);
+        if (ctype_digit((string) $date)) {
+            $date = new DateTime('@'.$date);
+            $date->setTimezone(new DateTimeZone(date_default_timezone_get()));
+        } else {
+            $date = new DateTime($date);
+        }
     }
 
     return $date->format($format);