ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Occasional, incorrect edit_date value

October 25, 2011 10:50am

Subscribe [2]
  • #1 / Oct 25, 2011 10:50am

    UMstratcomm

    44 posts

    Greetings,
    I use the following code to display either the edit_date or entry_date of a entry, depending, on which one is more recent.

    <?php /*Display latest entry date*/ if ({edit_date format="%Y-%m-%d"} > {entry_date format="%Y-%m-%d"}){ ?> Reviewed {edit_date format="%Y-%m-%d"}. <?php } else { ?> Reviewed {entry_date format="%Y-%m-%d"}.<?php } ?>

    That being said, some of my entries display a far-future edit_date: for example, 2033-01-01.  I looked up one of the entries in the exp_weblog_titles table, and the edit_date field contained ‘20111025092943’; it appears that it did not convert to the correct timestamp.  This only appears to affect certain entries (probably about 2-5% of my entries).

    I also tried deleting one of the ‘faulty’ entries and recreating it…Then going in and editing the new entry, and it exhibits the same problem.

    I am running EE 1.71 Build 20110520.  I have disabled the extensions that I am running (LG Live Look; LG TinyMCE; NSM Publish Plus), but the problem still pops up (at least, with the above entry).  And, it is only on certain, apparently random entries.

    Can someone please direct me to the code/page that powers the edit_date, or recommend something else to try (perhaps overwriting the code/page with a default version)?

    Thanks in advance!

    UMStramcomm

  • #2 / Oct 26, 2011 12:19am

    John Henry Donovan

    12339 posts

    Hi UMstratcomm,

    While the entry date is Unix time the Edit date is a straight forward date string

    20111025092943 = 2011 10(Oct) 25th 09:29:43

    Does that help?

  • #3 / Oct 26, 2011 10:14am

    UMstratcomm

    44 posts

    Hi UMstratcomm,

    While the entry date is Unix time the Edit date is a straight forward date string

    20111025092943 = 2011 10(Oct) 25th 09:29:43

    Does that help?

    Thanks for the info, John.  Is there a specific, recommended method to display the edit_date, outside of the code that I included in my first post?

    Today, I edited another, existing entry, and the edit_date displayed as 2033-01-12; I am using {edit_date format="%Y-%m-%d"} to display the edit_date. 

    Regards,
    UMstratcomm

  • #4 / Oct 28, 2011 2:02am

    John Henry Donovan

    12339 posts

    UMstratcomm,

    To confirm t he correct syntax is as follows which you have right

    {edit_date format="%Y %m %d"}

    Are you using it outside the PHP as a test?

    can you try a weblog loop like the following. What kind of results does that retrieve?

    <ul>
    {exp:weblog:entries weblog="news" dynamic="off" limit="20"}
    <li>{edit_date format="%Y %m %d"} - {title}</li>
    {/exp:weblog:entries}
    </ul>
  • #5 / Oct 28, 2011 9:35am

    UMstratcomm

    44 posts

    UMstratcomm,

    To confirm t he correct syntax is as follows which you have right

    {edit_date format="%Y %m %d"}

    Are you using it outside the PHP as a test?

    can you try a weblog loop like the following. What kind of results does that retrieve?

    <ul>
    {exp:weblog:entries weblog="news" dynamic="off" limit="20"}
    <li>{edit_date format="%Y %m %d"} - {title}</li>
    {/exp:weblog:entries}
    </ul>

    John,
    With that code, the output appears fine:

    2011 05 18 - Auto Insurance
    2011 03 04 - General Liability
    2011 01 24 - Policies
    2011 01 24 - Policy on Purchasing Insurance

    On further review the problem appears to be tied to the use of exp:query.  Here is my original code, that skews the edit_date:

    {exp:query sql="SELECT e1.title, e1.entry_date, e1.edit_date, e2.field_id_2 FROM exp_weblog_titles e1, exp_weblog_data e2 WHERE e1.entry_id = e2.entry_id and e2.weblog_id = 82 and e1.url_title = 'risk_index' LIMIT 1"}
               <h1 id="contenttitle">Risk and Insurance Management</h1>
               {field_id_2}
               <?php /*Display latest entry date*/ if ({edit_date format="%U"} > {entry_date format="%U"}){ ?> Reviewed {edit_date format="%Y-%m-%d"}. <?php } else { ?> Reviewed {entry_date format="%Y-%m-%d"}.<?php } ?>
              {/exp:query}

    I replaced the above code with exp:weblog:entries, and it works fine:

    {exp:weblog:entries weblog="risk" dynamic="off" limit="1" url_title="risk_index"}
    <h1 id="contenttitle">Risk and Insurance Management</h1>
      {field_id_2}
      <?php /*Display latest entry date*/ if ({edit_date format="%U"} > {entry_date format="%U"}){ ?> Reviewed {edit_date format="%Y-%m-%d"}. <?php } else { ?> Reviewed {entry_date format="%Y-%m-%d"}.<?php } ?>
    {/exp:weblog:entries}

    I initially switched my index-based pages to use exp:query, mainly because I was having problems on templates with multiple queries (and using exp:query fixed the problem).  However, I have since moved the other queries to their own, embedded templates, so I should be able to use the above code as a fix.  I suspect that the query code needs some sort of date syntax applied to the edit_date, although I have noted that the problem only appears on random entries.

  • #6 / Oct 29, 2011 4:34pm

    Dan Decker

    7338 posts

    Hi UMstratcomm,

    Is there anything else we can assist you with?

    Cheers,

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases