Search code examples
expressionengine

How to return the most recent channel entry/comment date?


To be honest I'm not expecting an answer to this question. While it sounds simple, I think it's probably quite involved.

For a given channel I want to return one date/time - it will be either the latest channel entry date or the most recent comment date, whichever is the most recent date/time.

Cheers Lee


Solution

  • You can use the Statistics Module (as John said) but the following code will output either the comment or entry data like you requested:

    {exp:stats}
      {if last_comment_date > last_entry_date}
        {!-- Comment is more recent --}
        {last_comment_date format="..."}
      {if:else}
        {!-- Entry is more recent --}
        {last_entry_date format="..."}
      {/if}
    {/exp:stats}