Hello everyone,
I just expanded on Steve Sharpe’s Timesince plugin to include some additional functionality.
This plugin maintains the functionality that is in Steve’s plugin and expands to include future dates. I needed something to show how much time remained until certain dates for an events page so this works great for that.
By default, it gives the following output (depending on how much time there since/until the date):
Dates that have passed:
25 minutes ago
2 hours, 1 minute ago
6 days, 8 hours ago
3 months, 11 days ago
2 years, 3 months ago
Dates to come:
25 minutes
2 hours, 1 minute
6 days, 8 hours
3 months, 11 days
2 years, 3 months
You can use it in any entry or comment template. The basic syntax is this:
[/code]{exp:count_time:standard}
{entry_date} or {comment_date}
{/exp:count_time:standard}
Additionally, there are two optional parameters that can be passed to the function.
(1) seperator - The “seperator” parameter controls the character which appears between each unit. This is set to be a comma by default.
(2) ending - the “ending” paramter controls what appears at the end of the date. This is set to be ago by default for dates that have passed and blank for dates to come.
For example,
{exp:count_time:standard seperator="and" ending="have elapsed."}
{entry_date} or {comment_date}
{/exp:count_time:standard}
The above would yield: 2 hours and 1 minute have elapsed.
Lastly, there are seven other calls you can make within the {exp:count_time} tag to determine the output.
{exp:count_time:standard} outputs a two unit string (2 Months, 5 Days)
The below only output in one unit. They also take the optional ending paramater. The default is ago for past events and nothing for future events.
{exp:count_time:years} —> 1 year (ago)
{exp:count_time:months} —> 12 months (ago)
{exp:count_time:weeks}—> 52 weeks (ago)
{exp:count_time:days}—> 365 days (ago)
{exp:count_time:hours} —> 8,760 hours (ago)
{exp:count_time:minutes} —> 525,600 minutes (ago)
{exp:count_time:seconds}—> 31,536,000 seconds (ago)
Files are attached ![]()
EDIT:
Updated with Mark Bowen’s suggestion (see below).
EDIT:
Added language file
