Is it possible to show the current date in query language?

I think that is exactly the purpose here.


I just tested it and indeed, using date('Y') doesn’t work here. But we can use a little trick:

    copyright_text:
        label: Copyright Text
        type: text
        before: "© {{ page.year }}"

The in a page model or a page method named year(), return the date:

class SomePage extends Page
{
    public function year()
    {
        return date('Y');
    }
}

If you use this in the site.yml, use a custom site method.

3 Likes