diff --git a/src/Twig/Extension/TimeExtension.php b/src/Twig/Extension/TimeExtension.php index d672ae7..22d2e24 100644 --- a/src/Twig/Extension/TimeExtension.php +++ b/src/Twig/Extension/TimeExtension.php @@ -18,6 +18,7 @@ namespace Cake\TwigView\Twig\Extension; +use Cake\Chronos\Chronos; use Cake\Chronos\ChronosDate; use Cake\I18n\DateTime; use DateInterval; @@ -70,12 +71,12 @@ public function getFunctions(): array * * Includes shims for \Chronos\ChronosDate as Twig doesn't. * - * @param \Chronos\ChronosDate|\DateTimeInterface|\DateInterval|string $date The date to format. + * @param mixed $date The date to format. * @param ?string $format The format to use, null to use the default. * @param \DateTimeZone|string|false|null $timezone The target timezone, null to use system. */ public function formatDate( - ChronosDate|DateTimeInterface|DateInterval|string $date, + mixed $date, ?string $format = null, DateTimeZone|string|false|null $timezone = null ): string { @@ -85,6 +86,9 @@ public function formatDate( if ($date instanceof ChronosDate) { $date = $date->toDateString(); } + if ($date instanceof Chronos) { + $date = $date->toIso8601String(); + } return $this->coreExt->formatDate($date, $format, $timezone); }