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)

This commit is contained in:
Fabien Potencier
2011-05-28 16:36:42 +02:00
parent d8eafa02f2
commit 9c07baf8e5
+6 -1
View 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);