forked from twigphp/Twig
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support DateTimeInterface (PHP 5.5) if available
- Loading branch information
1 parent
09c386b
commit ca61fac
Showing
2 changed files
with
41 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--TEST-- | ||
"date" filter | ||
--CONDITION-- | ||
version_compare(phpversion(), '5.5.0', '>=') | ||
--TEMPLATE-- | ||
{{ date1|date }} | ||
{{ date1|date('d/m/Y') }} | ||
{{ date1|date('d/m/Y H:i:s', 'Asia/Hong_Kong') }} | ||
{{ date1|date('d/m/Y H:i:s', timezone1) }} | ||
{{ date1|date('d/m/Y H:i:s') }} | ||
|
||
{{ date2|date('d/m/Y H:i:s P', 'Europe/Paris') }} | ||
{{ date2|date('d/m/Y H:i:s P', 'Asia/Hong_Kong') }} | ||
{{ date2|date('d/m/Y H:i:s P', false) }} | ||
{{ date2|date('e', 'Europe/Paris') }} | ||
{{ date2|date('e', false) }} | ||
--DATA-- | ||
date_default_timezone_set('Europe/Paris'); | ||
return array( | ||
'date1' => new DateTimeImmutable('2010-10-04 13:45'), | ||
'date2' => new DateTimeImmutable('2010-10-04 13:45', new DateTimeZone('America/New_York')), | ||
'timezone1' => new DateTimeZone('America/New_York'), | ||
) | ||
--EXPECT-- | ||
October 4, 2010 13:45 | ||
04/10/2010 | ||
04/10/2010 19:45:00 | ||
04/10/2010 07:45:00 | ||
04/10/2010 13:45:00 | ||
|
||
04/10/2010 19:45:00 +02:00 | ||
05/10/2010 01:45:00 +08:00 | ||
04/10/2010 13:45:00 -04:00 | ||
Europe/Paris | ||
America/New_York |