Published by Mijingo

tips icon image

EE Insider Tips
Sponsored by Mijingo's EE 2 Screencasts

ExpressionEngine mini-howtos created by the EE Insider community.

Dynamically display Year from entries not from this year

  • Posted by Erik Reagan
  • April 14, 2010

I personally hate going to blog sites and not knowing when an article was published. I often see “June 2” but no year. Sometimes I’m actually interested in whether or not that means this June 2nd or last June second, or even an June from years ago.

Here is a simple way to automagically display the year once the entry is from “last year”. It’s just a simple conditional check against the date.

{entry_date format="%D %M %d"}{if {current_time format='%y'!= {entry_date format='%y'}}{entry_date format=', %Y'}{/if} 
Batdelfuego17:56 on 04.14.2010

Nice trick Erik!

I’ve red online an SEO trick suggested to not enter a date on a blog post so that people keep thinking that the post was new and keep commenting on it. If, by having a date, the post shows to be 3 years old, you feel less tempted to keep on the discussion in the comments… Less comments or action on a blog post, less chances of getting shared…

But I’m like you, I hate it when there is no date. smile

Erik Reagan17:58 on 04.14.2010

Thanks batdelfuego.

On the SEO note, it’s surely more important to keep updated relevant content on the site rather than comments on a 3 year old post. While I see some value in continued comments, I’d put much more weight on comments from newer posts smile

mr_dimsum09:33 on 04.15.2010

There’s also jQuery plugins like CuteTime (http://tpgblog.com/cutetime) which do some pretty awesome things, converting time stamps into “x hours ago” messages ala Facebook.

Jason Morehead09:44 on 04.15.2010

There are also one or two EE plugins that let you display relative dates (e.g., “x hours ago”). Personally, I’d go with something like that before a jQuery plugin (as much as I like jQuery).