From 9c07baf8e55a37f8190c7224fb00d4b2ff87db82 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 28 May 2011 16:36:42 +0200 Subject: [PATCH] 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) --- lib/Twig/Extension/Core.php | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) 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); -- 1.7.2.5