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

XF 1.1 Change details via date?

Discussion in 'XenForo Questions and Support' started by DaveL, Nov 12, 2012.

  1. DaveL

    DaveL Well-Known Member


    I currently use the code below to display different text/image art different times of the day.

    <xen:if is="{xen:time $serverTime, 'G:i'} >= '00:00' AND {xen:time $serverTime, 'G:i'} < '01:30' AND {xen:time $serverTime, 'D'} == 'Mon'">
    <a href="{$xenOptions.boardUrl}/pages/OnAir__StephenKennett"><img src="{$xenOptions.boardUrl}/images/presenters/DSCF1157.jpg" style="width: 180px; height:155px; margin-bottom: 5px;"></a><br><a href="{$xenOptions.boardUrl}/pages/OnAir__StephenKennett">Stephen Kennett</a>
    Can anyone advise how I can get this to display on different dates?

    EG: 14th November, 21st November and the 28th November?

    Any help appreciated
  2. Chris D

    Chris D XenForo Developer Staff Member

    The code is similar:

    <xen:if is="{xen:date $serverTime, 'd/m/y'} >= '14/11/12' AND {xen:date $serverTime, 'd/m/y'} < '21/11/12' AND {xen:date $serverTime, 'd/m/y'} == '28/11/12'">


    You can actually combine the two if you're feeling adventurous.

    There's a compiler function called datetime that accepts similar arguments.

    So something like:

    <xen:if is="{xen:datetime $serverTime, 'd/m/y, G:i'} >= '14/11/12, 17:00' AND {xen:datetime $serverTime, 'd/m/y, G:i'} < '21/11/12, 03:00' AND {xen:date $serverTime, 'd/m/y'} == '28/11/12'">

    That would display whatever on the date 14th November after 5PM and before 3AM on the 21st November and all day on the 28th November.
    Jake Bunce likes this.
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Strictly speaking, I'm not sure how inequality works with two strings. 'string1' <= 'string2' may not work as you expect, but there are no other suitable functions available to the templates.

Share This Page