twig_date_converter example

function twig_date_format_filter(Environment $env$date$format = null, $timezone = null)
{
    if (null === $format) {
        $formats = $env->getExtension(CoreExtension::class)->getDateFormat();
        $format = $date instanceof \DateInterval ? $formats[1] : $formats[0];
    }

    if ($date instanceof \DateInterval) {
        return $date->format($format);
    }

    return twig_date_converter($env$date$timezone)->format($format);
}

/** * Returns a new date object modified. * * {{ post.published_at|date_modify("-1day")|date("m/d/Y") }} * * @param \DateTimeInterface|string $date A date * @param string $modifier A modifier string * * @return \DateTimeInterface */
Home | Imprint | This part of the site doesn't use cookies.