mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 10:56:38 +00:00
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
This commit is contained in:
@@ -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()));
|
||||
|
||||
Reference in New Issue
Block a user