From: Fabien Potencier Date: Sat, 28 May 2011 14:36:42 +0000 (+0200) Subject: fixed timezone when using the date filter with a UNIX timestamp (it now uses the... X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=9c07baf8e55a37f8190c7224fb00d4b2ff87db82;p=web%2Fkonrad%2Ftwig.git fixed timezone when using the date filter with a UNIX timestamp (it now uses the default timezone instead of UTC to mimics the date() function behavior) --- diff --git a/lib/Twig/Extension/Core.php b/lib/Twig/Extension/Core.php index 61429d8..96b9d42 100644 --- a/lib/Twig/Extension/Core.php +++ b/lib/Twig/Extension/Core.php @@ -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);