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

<p>Try this instead...</p>

<pre><code>{{ entry.postDate|date(global__siteMetadata.gv__articleDateFormat) }}
</code></pre>

CC BY-SA 4.0
2019-04-06T18:42:49.393Z
2019-04-06T18:42:49.393Z
Lindsey D
<p>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:</p>

<pre><code>{{ entry.postDate|date('Y.d.m') }}
</code></pre>

<p>And replace it with something like this:</p>

<pre><code>{{ entry.postDate|date('{{ global__siteMetadata.gv__articleDateFormat }}') }}
</code></pre>

<p>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:</p>

<pre><code>{{ 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 }}
</code></pre>

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

<datetime><globals>
Can I use a Global Variable for date/time?
# Can I use a Global Variable for date/time?

(Asked by: username_0 on 2019-04-06)

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?

**Tags:** datetime, globals

---

## 1 answers

### Answer by username_1 on 2019-04-06. Score: 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) }}


---

