Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Allow setting of timezone on twig_date_format_filter method

  • Loading branch information...
commit 65937619507a2fe2868415695a8a7cfcec1732bf 1 parent 027f489
Josh Turmel jturmel authored

Showing 1 changed file with 9 additions and 1 deletion. Show diff stats Hide diff stats

  1. +9 1 lib/Twig/Extension/Core.php
10 lib/Twig/Extension/Core.php
@@ -201,7 +201,7 @@ public function getName()
201 201 }
202 202 }
203 203
204   -function twig_date_format_filter($date, $format = 'F j, Y H:i')
  204 +function twig_date_format_filter($date, $format = 'F j, Y H:i', $timezone = NULL)
205 205 {
206 206 if (!$date instanceof DateTime) {
207 207 if (ctype_digit((string) $date)) {
@@ -212,6 +212,14 @@ function twig_date_format_filter($date, $format = 'F j, Y H:i')
212 212 }
213 213 }
214 214
  215 + if ($timezone !== NULL) {
  216 + if (!$timezone instanceof DateTimeZone) {
  217 + $timezone = new DateTimeZone($timezone);
  218 + }
  219 +
  220 + $date->setTimezone($timezone);
  221 + }
  222 +
215 223 return $date->format($format);
216 224 }
217 225

0 comments on commit 6593761

Please sign in to comment.
Something went wrong with that request. Please try again.