0

I need to use an advanced conditional with Low Variables and am having trouble getting it to work. I believe it's a parse order thing but am not sure how to get around it.

I am checking the current date/time against 2 Low Variables to see if the current date/time is in between 2 variables.

{if '{current_time format="%F %d - %g:%i %a"}' >= '{date_start}' AND '{current_time format="%F %d - %g:%i %a"}' <= '{date_end}'}
Show some content
{/if}

date_start & date_end are the Low Variables & I have both of them set to parse early.

Any help is appreciated.

0

This conditional will never work because the format you chose. "%F %d - %g:%i %a" isn't a number and just numbers can use >, >=, < and <=.

You need to format all variables used in this conditionals as seconds since Epoch.

{if {current_time format="%U"} >= {date_start} AND {current_time format="%U"} <= {date_end} }
  Show some content
{/if}

Remember that your Low Variables need to be formated this way too! If you can't, there are some addons which can change the format of a date. Low has one.

{exp:low_nice_date date="{date_start}" format="%U"}

So:

{if {current_time format="%U"} >= {exp:low_nice_date date="{date_start}" format="%U"} AND {current_time format="%U"} <= {exp:low_nice_date date="{date_end}" format="%U"} }
  Show some content
{/if}
| improve this answer | |
  • That did the trick! Thanks! It does make it a little more difficult for the client to edit this since they have to provide the seconds since Epoch. Any thoughts on making this easier for them? – mediapimp Aug 5 '13 at 17:38
  • Sure! I gonna update my answer. – Robson Sobral Aug 5 '13 at 17:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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