Is this possible with a <Xen IF>? Message displayed based on day

DaveL

Well-known member
Is there an <if> command I could use to have different text displayed depending on the day of the week?

Eg:

<if Monday>
Hello its Monday </if>
<if Tuesday>
Hello its Tuesday</if>

If that is possible, Is it possible to break it down even further, is there an <if> command for time of day?

Eg:
<if 0800-1100>
Good Morning!</if>
<if 1100-1300>
Its Lunchtime!</if>

I used something similar many years ago n vbulletin, however it was built into a skin I purchased so cant go back and look at the code.

Fingers crossed it will be possible!

Dave
 
<xen:if is="{xen:time $serverTime, 'G:i'} >= '00:01' AND {xen:time $serverTime, 'G:i'} < '20:30' AND {xen:time $serverTime, 'D'} == 'Fri'">
<a href="{$xenOptions.boardUrl}/pages/OnAir__DCRNS"><img src="{$xenOptions.boardUrl}/images/dcrlogo.jpg" style="width: 180px; height:155px; margin-bottom: 5px;"></a><br><a href="{$xenOptions.boardUrl}/pages/OnAir__DCRNS">DCR Non-Stop</a>
</xen:if>
Can you see any reason why this wouldnt be working? Its currently 02:04 hrs on Friday morning and nothing is being displayed.

All my others seem to follow the same format and they work, but this has got me stumped!
 
Just been having a play around, and if I turn it from
<xen:if is="{xen:time $serverTime, 'G:i'} >= '00:00' AND {xen:time $serverTime, 'G:i'} < '19:30' AND {xen:time $serverTime, 'D'} == 'Fri'">
<a href="{$xenOptions.boardUrl}/pages/OnAir__DCRNS"><img src="{$xenOptions.boardUrl}/images/dcrlogo.jpg" style="width: 180px; height:155px; margin-bottom: 5px;"></a><br><a href="{$xenOptions.boardUrl}/pages/OnAir__DCRNS">DCR Non-Stop</a>
</xen:if>

to

<xen:if is="{xen:time $serverTime, 'G'} >= '00' AND {xen:time $serverTime, 'G'} < '19' AND {xen:time $serverTime, 'D'} == 'Fri'">
<a href="{$xenOptions.boardUrl}/pages/OnAir__DCRNS"><img src="{$xenOptions.boardUrl}/images/dcrlogo.jpg" style="width: 180px; height:155px; margin-bottom: 5px;"></a><br><a href="{$xenOptions.boardUrl}/pages/OnAir__DCRNS">DCR Non-Stop</a>
</xen:if>

Cant believe it was all working fine the other day! Any ideas at all, im stumped!
 
It works fine for me.

Maybe it isn't really Friday. The current day / time is based on your user's time zone preference:

http://xenforo.com/community/account/preferences

If you are logged out then it uses this time zone:

Admin CP -> Home -> Options -> Basic Board Information -> Guests' Time Zone

You can add some debug code to your templates to see what each time function is returning:

Code:
G:i = {xen:time $serverTime, 'G:i'}<br />
D = {xen:time $serverTime, 'D'}<br />
 
Thanks Jake.

Seems to be working fine this morning. When I was playing around with it last night, it was accepting that it was Friday, just didnt like have minutes because it worked fine if I changed it to just hours.

Will see if the same happens again tonight!
 
How frustrating! Its stopped working again!

Checked all the settings for timezones and they are all correct. Also tried the debug code and it comes back with:

G:i = 9:44
D = Thu

<xen:if is="{xen:time $serverTime, 'G:i'} >= '00:01' AND {xen:time $serverTime, 'G:i'} < '19:29' AND {xen:time $serverTime, 'D'} == 'Thu'">
<img src="{$xenOptions.boardUrl}/images/dcrlogo.jpg" style="width: 140px; height:100px; margin-bottom: 5px;"></a>
<br><strong><a href="{$xenOptions.boardUrl}/pages/OnAir__DCRNS">DCR Non-Stop</a></strong>
</xen:if>

Thats the current code im using, Can you see anything that might stop it from appearing?

The strange thing is, if I change it to

<xen:if is="{xen:time $serverTime, 'G'} >= '00' AND {xen:time $serverTime, 'G'} < '19' AND {xen:time $serverTime, 'D'} == 'Thu'">
<img src="{$xenOptions.boardUrl}/images/dcrlogo.jpg" style="width: 140px; height:100px; margin-bottom: 5px;"></a>
<br><strong><a href="{$xenOptions.boardUrl}/pages/OnAir__DCRNS">DCR Non-Stop</a></strong>
</xen:if>

It works fine. It sometimes dosent appear to like the minutes :confused: Is there any other way to work around this at all?
 
Top Bottom