Skip to content

Commit

Permalink
adds support for timestamp to twig filters
Browse files Browse the repository at this point in the history
  • Loading branch information
pawbuj committed Mar 19, 2019
1 parent b55a728 commit 6e6afcd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib/Templating/Twig/DateTimeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,21 @@ public function getFilters(): array
}

/**
* @param \DateTimeInterface|null $date
* @param mixed $date
* @param \EzSystems\EzPlatformUser\UserSetting\DateTimeFormat\FormatterInterface $formatter
*
* @return string
*/
public function format(?DateTimeInterface $date = null, FormatterInterface $formatter): string
public function format($date = null, FormatterInterface $formatter): string
{
if ($date === null) {
$date = new DateTimeImmutable();
}

if(is_int($date)) {
$date = new DateTimeImmutable('@'.$date);
}

return $formatter->format($date);
}
}

0 comments on commit 6e6afcd

Please sign in to comment.