• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.5 conditional to show only if a thread is older than 3 days?


Active member
was wondering if I could get some help --

is it possible to write a template conditional that will only be true if the thread that is being displayed is older than, say, 3 days? (ie, "show this part of the template if a thread was created three days before or earlier.")



Well-known member
Yes, this should be possible, because the thread_view template has "$thread.post_date" in the description, you can use that to compare against the current date (which maybe could be: $serverTime) You can format the way the time is for both using {xen:datetime string, format}, if I remember correctly. Hopefully this gets you started.


Well-known member
thanks for this -- i'll try to dig up some template code where date comparisons were done & see what I can do.
I threw this in my thread_view:
<div>debug: post_date: {xen:datetime $thread.post_date}, server: {$serverTime}</div>

and output like this:
debug: post_date: Wednesday at 6:09 PM, server: 1490386886

It's a matter of getting them both in the same format, and then comparing them against each other.

I think we can do this! :D


Active member
cool, so the last step is to get server.time into unix format? (that's what the servertime is in, right?)
then do the comparison.