This plugin requires PHP version > 5.3.0 and will display an error otherwise.
Wrap your conditionals in {exp:cc_time_difference}
tags.
The tag has the following parameters:
The first time to calculate difference with. (Required.)
The second time to calculate difference with. (Required.)
Whether to include the total number of units, or only the remainder.
The order the times are passed does not matter, the absolute difference will be calculated.
CC Time Difference creates the following variables to use:
The total number of years between the two dates.
The total number of months between the two dates.
The total number of days between the two dates.
The total number of weeks between the two dates.
The total number of hours between the two dates.
The total number of minutes between the two dates.
The total number of seconds between the two dates.
CC Time Difference creates the following conditional parameters to use:
Compares the two times and returns a negative integer if time_1
is earlier, a positive integer if time_2
is earlier or 0
if they are equal.
{exp:channel:entries channel="compare_time"}
{exp:cc_time_difference time_1="{entry_date}" time_2="{current_time}"}
{if compare < 0}
{if days == 1}
Posted 1 day ago.
{if:elseif weeks < 1}
Posted {days} days ago.
{if:elseif weeks == 1}
Posted 1 week ago.
{if:else}
Posted {weeks} weeks ago.
{/if}
{if:else}
I am from the future; I come in peace!
{/if}
{/exp:cc_time_difference}
{/exp:channel:entries}