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

Plugin: Timesince

Development and Programming

Steve [at] Gleam.'s avatar
Steve [at] Gleam.
27 posts
18 years ago
Steve [at] Gleam.'s avatar Steve [at] Gleam.

You can see the plugin in use at stevepsharpe.com in all articles and comments.

Basically what it does is show you how long ago an entry or comment was posted in english, below are various examples of what the plugin can output:

10 minutes ago 2 hours, 1 minute ago 7 days, 10 hours ago 5 months, 21 days ago 3 years, 1 month ago

To use the plugin it’s simply a case of just adding the plugin code within either an exp:weblog:entries or exp:comment:entries tag pair.

exp:weblog:entries example

{exp:timesince}
{entry_date}
{/exp:timesince}

exp:comment:entries example

{exp:timesince}
{comment_date}
{/exp:timesince}

More info about this plugin

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
18 years ago
Ingmar Greil's avatar Ingmar Greil

Nice work. Bookmarked, might come in handy somewhere.

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
18 years ago
Lisa Wess's avatar Lisa Wess

Just as a note, for the weblog entries tag, you can use {relative_date} for this. =)

       
Steve [at] Gleam.'s avatar
Steve [at] Gleam.
27 posts
18 years ago
Steve [at] Gleam.'s avatar Steve [at] Gleam.

Oops, I didn’t even realize =]

Still this plugin will come in handy for comments.

       
LeuMund's avatar
LeuMund
4 posts
18 years ago
LeuMund's avatar LeuMund

Nice, but why not make a parameter that after for example 3 days it switch to date view. ?

       
Luke Stevens's avatar
Luke Stevens
80 posts
18 years ago
Luke Stevens's avatar Luke Stevens

Oh I like how it only goes to only two levels (hours minutes, days hours, months days etc) ! That makes it a bit tidier than {relative_date}.

       
ropeadope's avatar
ropeadope
98 posts
16 years ago
ropeadope's avatar ropeadope

great plugin! is it possible to mod the code so that it only displays the # of days since the entry date?

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
16 years ago
Ingmar Greil's avatar Ingmar Greil

Take a look at the code, this should be trivial to achieve.

       
Danny T.'s avatar
Danny T.
426 posts
16 years ago
Danny T.'s avatar Danny T.

Is there an alternative to this plugin now? I recall seeing something else other than this one on the forums.. I like this concept, but I only want the Timesince plugin to apply only to entries within the last 24 hours and if articles are older than that, it simply displays the actual date.

If anybody would care to elaborate on how this can be achieved, or whether something out there already does this, much welcome!~

       
Tim Stackhouse's avatar
Tim Stackhouse
62 posts
16 years ago
Tim Stackhouse's avatar Tim Stackhouse

You might be able to rig up something like this (using Mark’s idea from this thread: http://ellislab.com/forums/viewthread/112695/#569361):

Adjust the date formats to change up your window (it’s not terribly fine grained). I have not tested this, but it should work.

{if "{current_time format="%d/%m/%y"}" == "{entry_date format="%d/%m/%y"}"}
{exp:timesince}
{entry_date}
{/exp:timesince} 
{if:else}
{entry_date}
{/if}

EDIT: It looks like Steve changed up his site and the plugin has gone missing. I can’t test it if I wanted to (which I sort of do now).

       
BMeunier's avatar
BMeunier
11 posts
15 years ago
BMeunier's avatar BMeunier

I’ve made a new version of this plugin (http://ellislab.com/forums/viewthread/129091/) and it’s available here: http://www.benoitmeunier.info/ee/plugins/timesince2/

Do not hesitate to tell me what you think!

       
PixelGrinch's avatar
PixelGrinch
48 posts
15 years ago
PixelGrinch's avatar PixelGrinch

BMeunier: Using your plugin as described: {exp:timesince}{entry_date}{/exp:timesince} puts out only the date of the entry for me and nothing else. Might wanna look into it a bit more. 1.6.7 is the version of EE that I am currently using.

       
BMeunier's avatar
BMeunier
11 posts
15 years ago
BMeunier's avatar BMeunier

@PixelGrinch: if you entry is older than one month, you only have the date. I’ve built it that way because I don’t think it’s relevant to have something like “1 year and 3 months ago…” I think after one month, it’s easier to understand with a date.

       

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.