1

Have an instance where there are two entries - one needs to be shown for six months of the year and the other for the second six months.... looking at a conditional which essentially says:

if date_range = January-June

Show this

If else

Show this

Is it doable with EE's native conditionals or does it need another approach?

1 Answer 1

4

The following conditional will achieve what you want:

{if {current_time format="%m"} <= 6}
  <p>do Jan through June</p>
{if:else}
  <p>do July through December</p>
{/if}

Edit: Replying to request for March-thru-September date range:

Since the %m flag on the date format represents each month as a number (and conveniently one-based at that), to achieve what you would like you would simply change the code to:

{if {current_time format="%m"} >= 3 && {current_time format="%m"} <= 9}
    <p>do March through September</p>
{if:else}
    <p>do January, February, October, November or December</p>
{/if}
2
  • Is there any way to modify this conditional to a specific range? Say March to September for example?
    – segovius
    Commented Jul 1, 2014 at 10:51
  • See revised answer.
    – dashard
    Commented Jul 2, 2014 at 4:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.