$format = $date instanceof DateInterval ? $formats[1] : $formats[0];
}
- if ($date instanceof DateInterval || $date instanceof DateTime) {
+ if ($date instanceof DateInterval) {
+ return $date->format($format);
+ }
+
+ if ($date instanceof DateTime) {
if (null !== $timezone) {
$date = clone $date;
$date->setTimezone($timezone instanceof DateTimeZone ? $timezone : new DateTimeZone($timezone));
{{ date2|date }}
{{ date2|date('d/m/Y') }}
{{ date2|date('d/m/Y H:i:s', 'Europe/Paris') }}
+{{ date2|date('d/m/Y H:i:s', timezone1) }}
{{ date2|date('d/m/Y H:i:s') }}
{{ date3|date }}
{{ date3|date('d/m/Y') }}
'date4' => 1286199900,
'date5' => -86410,
'date6' => new DateTime('2010-10-04 13:45', new DateTimeZone('America/New_York')),
+ 'timezone1' => new DateTimeZone('America/New_York'),
)
--EXPECT--
October 4, 2010 13:45
October 4, 2010 13:45
04/10/2010
04/10/2010 15:45:00
+04/10/2010 09:45:00
04/10/2010 13:45:00
October 4, 2010 13:45
04/10/2010
--CONDITION--
version_compare(phpversion(), '5.3.0', '>=')
--TEMPLATE--
-{{ date6|date }}
-{{ date6|date('%d days %h hours') }}
+{{ date1|date }}
+{{ date1|date('%d days %h hours') }}
+{{ date1|date('%d days %h hours', timezone1) }}
--DATA--
date_default_timezone_set('UTC');
return array(
- 'date5' => -86410,
- 'date6' => new DateInterval('P2D'),
+ 'date1' => new DateInterval('P2D'),
+ // This should have no effect on DateInterval formatting
+ 'timezone1' => new DateTimeZone('America/New_York'),
)
--EXPECT--
2 days
2 days 0 hours
+2 days 0 hours