Calculate difference between two dates in Webform I am trying to calculate a difference in days between (a) the date a Webform was completed and (b) an "Event Date" field on the Webform. I have added a Computed Twig field to the webform and attempted to use this code (similar to https://stackoverflow.com/a/27205095/1357555):

{% set difference = date(data.event_date).diff(date(completed)) %}
{% set leftDays = difference.days %}


However, I am getting an error message when attempting to save the field.


  Computed value/markup is not valid.
  
  
  Calling "diff" method on a "DateTime" object is not allowed in "{# inline_template_start #}{{ completed|date }} {{ data.date_needed|date }} {% set difference = date(data.event_date).diff(date(completed)) %} {% set leftDays = difference.days %}" at line 4.
  
  
  Failed to render computed Twig value due to error.
This is a bug in the Webform module. I created the below ticket to address this issue.

Improve Computed Twig element validation to support complex calculations