1

The goal is to create a global variable that allows the user to specify how they would like to format the date/time for entries. I'd like to remove the hardcoded format shown here:

{{ entry.postDate|date('Y.d.m') }}

And replace it with something like this:

{{ entry.postDate|date('{{ global__siteMetadata.gv__articleDateFormat }}') }}

The user would add "Y.d.m" or any other PHP date format they like through the global field in the CMS. But when I use this, I get the following output:

{{ 1THURSDAY2019PMTHURSDAY__001631AMERICA/CHICAGOMARAMERICA/CHICAGO31PM21PM31PM.1CT__PMTHU, 21 MAR 2019 13:16:00 -050031162019-03-21T13:16:00-05:00THURSDAYAMERICA/CHICAGOTHUPM31AMERICA/CHICAGOMARCH2019THU, 21 MAR 2019 13:16:00 -050003PM31 }}

Obviously, the global variable is not being parsed. Any thoughts on how to make this happen?

1

You never need to nest Twig tags. It looks like {{ glo... is all being processed (or attempted to process) as PHP date shorthand codes.

Try this instead...

{{ entry.postDate|date(global__siteMetadata.gv__articleDateFormat) }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.