We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How to determine whether an entry has a future publication date?

Development and Programming

fogcity's avatar
fogcity
260 posts
about 13 years ago
fogcity's avatar fogcity

I need to determine whether the current entry has a publication date in the future.

That is, I need to compare the entry_date to the current_time. I would greatly prefer to do this with EE tags, without the help of PHP or plugins.

But both of these attempts:

{if "{entry_date}" > "{current_time}"}
   UPCOMING EVENT
{/if}

{if "{entry_date format='%U'}" > "{current_time format='%U'}"}
   UPCOMING EVENT
{/if}

Result in this error:

Parse error: syntax error, unexpected T_STRING in /home/lavinias/public_html/ee_system/expressionengine/libraries/Functions.php(683) : eval()'d code on line 42

And this attempt:

{if entry_date > current_time}
   UPCOMING EVENT
{/if}

outputs nothing, regardless.

What is the recommended method?

       
travisb's avatar
travisb
172 posts
about 13 years ago
travisb's avatar travisb

Would using the start_on parameter work for you? http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#start-on

       
fogcity's avatar
fogcity
260 posts
about 13 years ago
fogcity's avatar fogcity
Would using the start_on parameter work for you? http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#start-on

Thanks for the suggestion but this won’t work for me.

The start_on parameter does not work with custom date fields.

       
travisb's avatar
travisb
172 posts
about 13 years ago
travisb's avatar travisb

I didn’t see a custom date field in your example, so what about this:

{if '{my_date_field format="%U"}' >= '{current_time format="%U"}'}
     something
{/if}
       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.