Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

merged branch phiamo/master (PR #454)

Commits
-------

5fa0094 Added Capability to format DateInterval via twig date filter

Discussion
----------

Added Capability to format DateInterval via twig date filter

hi,
i was wondering why twig couldn't format my DateInterval and added it.

Either this is ok for you or we should add something similar for DateInterval because it uses a little bit different syntax to format its string (e.g. prepend with "%")

Cheers Phil
  • Loading branch information...
commit 6d5a070fac20d4dd3dace363583cbaabb57c8298 2 parents a188f97 + 5fa0094
@fabpot authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/Twig/Extension/Core.php
View
2  lib/Twig/Extension/Core.php
@@ -221,7 +221,7 @@ function twig_cycle($values, $i)
*/
function twig_date_format_filter($date, $format = 'F j, Y H:i', $timezone = null)
{
- if (!$date instanceof DateTime) {
+ if (!$date instanceof DateTime && !$date instanceof DateInterval) {
if (ctype_digit((string) $date)) {
$date = new DateTime('@'.$date);
$date->setTimezone(new DateTimeZone(date_default_timezone_get()));
Please sign in to comment.
Something went wrong with that request. Please try again.