How can I rewrite the date in search kit so that it displays a date '7 days prior'? Field is [start_date] of an event. One week before is the deadline for submissions. I just want to display that date.

Any insight appreciated.

1 Answer 1


This works as a rewrite rule for a search display but see caveats below. Replace the Y-m-d with whatever date format you like.

{capture assign="step1"}{"[start_date]"|date_format:"%s"}{/capture}{capture assign="step2"}{$step1-7*24*60*60}{/capture}{$step2|date_format:"%Y-%m-%d"}


  • Will eventually stop working in a future version of php (the date_format modifier uses strftime which is deprecated in php 8)
  • In certain rare situations in leap years and for dates crossing DST boundaries it may be off by 1 day.
  • "%s" isn't available on all systems (e.g. windows)

The last two may not be of much concern. The first one depends on how aggressively you like to update php version.

  • thank you! That's a great answer, and it works beautifully. The only issue that I'll need to eventually deal with is php8, and I'm sure there will be a workaround. Much appreciated!
    – shibetpc
    Feb 26, 2023 at 14:03

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.