Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Extension/CoreExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ public function convertDate($date = null, $timezone = null)
if (ctype_digit($asString) || ('' !== $asString && '-' === $asString[0] && ctype_digit(substr($asString, 1)))) {
$date = new \DateTime('@'.$date);
} else {
$date = new \DateTime($date);
$date = new \DateTime($date, false !== $timezone ? $timezone : $this->getTimezone());
}

if (false !== $timezone) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/filters/date.test
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@ January 28, 2010 15:00
January 28, 2010 15:00

January 28, 2010 15:00
January 28, 2010 22:00
January 28, 2010 15:00
13 changes: 13 additions & 0 deletions tests/Fixtures/filters/date_relative_timezone.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--TEST--
"date" filter with relative dates and timezone
--TEMPLATE--
{{ "today"|date('e', 'Australia/Sydney') }}
{{ "today"|date('e', 'Europe/Paris') }}
{{ "today"|date('e', 'UTC') }}
--DATA--
date_default_timezone_set('UTC');
return []
--EXPECT--
Australia/Sydney
Europe/Paris
UTC
4 changes: 2 additions & 2 deletions tests/Fixtures/filters/date_time_zone_conversion.test
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ October 4, 2010 11:45
04/10/2010 07:45:00
04/10/2010 11:45:00

October 4, 2010 11:45
October 4, 2010 13:45
04/10/2010

October 4, 2010 13:45
Expand All @@ -88,4 +88,4 @@ January 28, 2010 15:00
January 28, 2010 15:00

January 28, 2010 15:00
January 28, 2010 22:00
January 28, 2010 15:00