This hook is executed whenever \Contao\Date::parse is used. \Contao\Date::parse allows you to format a date (timestamp) using the locale of the current request. The hook allows you to customize the date format.


  1. string `$formattedDate

    The already formatted date.

  2. string $format

    The requested date format.

  3. int $timestamp

    The given timestamp. Can be null.

Return Values

A string containing the formatted date.


// src/EventListener/ParseDateListener.php
namespace App\EventListener;

use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;

class ParseDateListener
    public function __invoke(string $formattedDate, string $format, ?int $timestamp): string
        // Modify or create your own formatted date …

        return $formattedDate;