<p>The entry will be passed to this template as a variable named <code>object</code>. When you want to reference its properties you have two options:</p>

<ul>
<li><code>{postDate}</code> (single braces)</li>
<li><code>{{object.postDate}}</code> (regular Twig syntax)</li>
</ul>

<p>The first one is just a shortcut for the second one. When Craft is getting ready to pass your Title Format template off to Twig, the first thing it will do is find any of those shortcut tags and swap ten with the full Twig syntax.</p>

<p>So in your case here's what you should do:</p>

<pre><code>New Arrivals for {% if object.postDate %}{postDate|date('M j, Y')}{% else %}{{ now|date('M j, Y') }}{% endif %}
</code></pre>

CC BY-SA 3.0
2014-09-23T14:33:49.177Z
Thanks, @Brandon. I read through the docs but got confused about how the single bracket syntax worked with the normal (double bracket) Twig syntax. Thanks again for clearing that up!
Ray
CC BY-SA 3.0
2014-09-23T15:17:19.147Z
@Bitmanic Thanks for the feedback! Just updated the docs - hopefully this will make more sense for the next poor soul. http://buildwithcraft.com/docs/sections-and-entries#dynamic-entry-titles
Brandon Kelly
CC BY-SA 3.0
2014-09-23T16:02:01.893Z
Holy smokes, that edit makes it clear as day. Thanks so much, and keep up the stellar work.
Ray
CC BY-SA 4.0
2021-11-04T10:16:33.127Z
Thx heaps - that worked great for me
bhu Boue vidya
CC BY-SA 3.0
2014-09-23T14:17:57.237Z
2014-09-23T14:17:57.237Z
Brandon Kelly
<p>I'm trying to generate titles for a section's entries based off of the given post date (if it exists). Here's the configuration I've got in the Title Format field for this section's entry types:</p>

<p><code>New Arrivals for {% if postDate %}{{ postDate|date('M j, Y') }}{% else %}{{ now|date('M j, Y') }}{% endif %}</code></p>

<p>I expect that, upon saving each new entry, Craft would build a title based off of the post date. Unfortunately, it always builds off of the current date - even with a more straightforward title format configuration:</p>

<p><code>New Arrivals for {{ postDate|date('M j, Y') }}</code></p>

<p>I understand that the user doesn't have to fill out the post date fields, but it appears that Craft creates a post date for every entry (and even does so <em>before</em> it writes the date created field to the database).</p>

<p>With that in mind, why wouldn't the above title format configurations work? Am I missing something? Any and all help is appreciated.</p>

<sections><titles>
Use postDate in section title format field
# Use postDate in section title format field

(Asked by: username_0 on 2014-09-23)

I'm trying to generate titles for a section's entries based off of the given post date (if it exists). Here's the configuration I've got in the Title Format field for this section's entry types:

`New Arrivals for {% if postDate %}{{ postDate|date('M j, Y') }}{% else %}{{ now|date('M j, Y') }}{% endif %}`

I expect that, upon saving each new entry, Craft would build a title based off of the post date. Unfortunately, it always builds off of the current date - even with a more straightforward title format configuration:

`New Arrivals for {{ postDate|date('M j, Y') }}`

I understand that the user doesn't have to fill out the post date fields, but it appears that Craft creates a post date for every entry (and even does so *before* it writes the date created field to the database).

With that in mind, why wouldn't the above title format configurations work? Am I missing something? Any and all help is appreciated.

**Tags:** sections, titles


---

## 1 answers

### Answer by username_1 on 2014-09-23. Score: 6 | Accepted answer

The entry will be passed to this template as a variable named object. When you want to reference its properties you have two options:

{postDate} (single braces)
{{object.postDate}} (regular Twig syntax)

The first one is just a shortcut for the second one. When Craft is getting ready to pass your Title Format template off to Twig, the first thing it will do is find any of those shortcut tags and swap ten with the full Twig syntax.
So in your case here's what you should do:
New Arrivals for {% if object.postDate %}{postDate|date('M j, Y')}{% else %}{{ now|date('M j, Y') }}{% endif %}

> **Comments:**
> **username_0**: Thanks, @Brandon. I read through the docs but got confused about how the single bracket syntax worked with the normal (double bracket) Twig syntax. Thanks again for clearing that up!  
> **username_1**: @Bitmanic Thanks for the feedback! Just updated the docs - hopefully this will make more sense for the next poor soul. http://buildwithcraft.com/docs/sections-and-entries#dynamic-entry-titles  
> **username_0**: Holy smokes, that edit makes it clear as day. Thanks so much, and keep up the stellar work.  
> **username_2**: Thx heaps - that worked great for me  

---

