diff --git a/app/bundles/CoreBundle/Config/config.php b/app/bundles/CoreBundle/Config/config.php index 53d798861aa..9667c38d44d 100644 --- a/app/bundles/CoreBundle/Config/config.php +++ b/app/bundles/CoreBundle/Config/config.php @@ -443,6 +443,7 @@ '%mautic.date_format_dateonly%', '%mautic.date_format_timeonly%', 'translator', + 'mautic.helper.core_parameters', ], 'alias' => 'date', ], diff --git a/app/bundles/CoreBundle/Templating/Helper/DateHelper.php b/app/bundles/CoreBundle/Templating/Helper/DateHelper.php index f273a648370..f1d7d67ca8e 100644 --- a/app/bundles/CoreBundle/Templating/Helper/DateHelper.php +++ b/app/bundles/CoreBundle/Templating/Helper/DateHelper.php @@ -11,6 +11,7 @@ namespace Mautic\CoreBundle\Templating\Helper; +use Mautic\CoreBundle\Helper\CoreParametersHelper; use Mautic\CoreBundle\Helper\DateTimeHelper; use Symfony\Component\Templating\Helper\Helper; use Symfony\Component\Translation\TranslatorInterface; @@ -32,6 +33,11 @@ class DateHelper extends Helper */ protected $translator; + /** + * @var CoreParametersHelper + */ + private $coreParametersHelper; + /** * DateHelper constructor. * @@ -46,7 +52,8 @@ public function __construct( $dateShortFormat, $dateOnlyFormat, $timeOnlyFormat, - TranslatorInterface $translator + TranslatorInterface $translator, + CoreParametersHelper $coreParametersHelper ) { $this->formats = [ 'datetime' => $dateFullFormat, @@ -55,8 +62,9 @@ public function __construct( 'time' => $timeOnlyFormat, ]; - $this->helper = new DateTimeHelper(null, null, 'local'); - $this->translator = $translator; + $this->helper = new DateTimeHelper(null, null, 'local'); + $this->translator = $translator; + $this->coreParametersHelper = $coreParametersHelper; } /** @@ -176,7 +184,7 @@ public function toText($datetime, $timezone = 'local', $fromFormat = 'Y-m-d H:i: $dt = $this->helper->getLocalDateTime(); if ($textDate) { - return $this->translator->trans('mautic.core.date.'.$textDate, ['%time%' => $dt->format('g:i a')]); + return $this->translator->trans('mautic.core.date.'.$textDate, ['%time%' => $dt->format($this->coreParametersHelper->getParameter('date_format_timeonly'))]); } else { $interval = $this->helper->getDiff('now', null, true);