For some reason i can't figure this one out. We have deals on our site that are set to expire on certain dates. These deals are sent out via email, so someone could click on a link after the deal has expired. If this happens, we would like to redirect them to the main deals page. My thought was to do this one of two ways:

  1. If the entry is "closed" redirect to {segment_2}. The problem is that expired entries don't automatically change to "closed" status. How would i do this?

  2. Use a conditional statement to either show page or redirect based on expiration date.. something like this:

        {if expiration_date < current_time}
            SHOW DEAL
        {if expiration_date > current_time}
            REDIRECT TO {segment_2} 

This isn't working either. I did a test with it to just show text based on the condition and both expired pages and live pages showed "SHOW DEAL". Obviously missing something here.

Please let me know if you have any suggestions. Thanks!

3 Answers 3


Well, what happens when you output

Expires - {expiration_date} 

Current Time - {current_time}

Does that output look like two values you can use comparisons with? You could use Low Nice Date to convert times and dates (I think, check the docs), or perhaps have you looked at this addon?


It looks out of date, but might work still. Test it on a dev site first. And also look around devot-ee, there might be a newer version or one by a different author.

  • I've looked at this, but doesn't it just expire all entries in a certain channel after a certain amount of time? Each entry we have has a specific expiration date. Commented Oct 21, 2015 at 21:01

Well, I think your conditional is inverted. Shouldn't it be?

{if expiration_date < current_time}

I can't test on an older version of eecms, but maybe the one you're using doesn't save the expiration_date as UNIX timestamp. In this case, try:

{if "{expiration_date format='%Y%m%d'}" < "{current_time format='%Y%m%d'}"}
  • I think he wants people redirected to the deals page, not 404's. And yeah, I noticed that too, that his conditionals where reversed for the intended affect.
    – jrothafer
    Commented Oct 21, 2015 at 19:17
  • Correct. I do not want a 404 page. Sorry i typed the example wrong. I have used this code above to try to accomplish what i want and it just doesn't work. Seems simple enough. I checked the expiration date of a live deal and one that has expired and they both are accurate (one expired, one expires in Dec). Neither one redirects using the code above. If i reverse the less than to greater than It redirects both? Commented Oct 21, 2015 at 20:58
  • Wait! @ChrisBrown, which version of EECMS are using?
    – Sobral
    Commented Oct 21, 2015 at 23:18
  • EE Version 2.9.0 Commented Oct 22, 2015 at 14:15
  • @ChrisBrown, did my update helped?
    – Sobral
    Commented Oct 22, 2015 at 15:15

The conditional was correct the whole time. I was missing the show_expired="yes" in the {exp:channel:entries. What was happening was that entry wasn't pulling at all so the conditional wasn't seeing anything. Once i added the show_expired it was able to see the expiration date to compare to. Thanks guys!

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.