mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 02:46:29 +00:00
merged branch jturmel/patch-1 (PR #367)
Commits
-------
6593761 Allow setting of timezone on twig_date_format_filter method
Discussion
----------
Allow setting of timezone on twig_date_format_filter method
This commit is contained in:
@@ -201,7 +201,7 @@ class Twig_Extension_Core extends Twig_Extension
|
||||
}
|
||||
}
|
||||
|
||||
function twig_date_format_filter($date, $format = 'F j, Y H:i')
|
||||
function twig_date_format_filter($date, $format = 'F j, Y H:i', $timezone = NULL)
|
||||
{
|
||||
if (!$date instanceof DateTime) {
|
||||
if (ctype_digit((string) $date)) {
|
||||
@@ -212,6 +212,14 @@ function twig_date_format_filter($date, $format = 'F j, Y H:i')
|
||||
}
|
||||
}
|
||||
|
||||
if ($timezone !== NULL) {
|
||||
if (!$timezone instanceof DateTimeZone) {
|
||||
$timezone = new DateTimeZone($timezone);
|
||||
}
|
||||
|
||||
$date->setTimezone($timezone);
|
||||
}
|
||||
|
||||
return $date->format($format);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user