0

In Drupal 8, I have a View formatted as a Table displaying a node type with two Date-Time fields. They are Start Date and End Date. Within the View I have them in the same column. I would like to alter how the End Date displays based on the Start Date. In particular, if the End Date is the same day as the Start date, I only want the time component displayed. I have created a Time date format for use elsewhere, that I assume will be referenced for this. In the event that the dates are different days, they need to use the default format.

I assume that one of the view hooks is what I need. But I am unsure of which one and do not know exactly what I would need to alter in the view's code.

0

You can override the output using twig code:

{% if field_date1.striptags == field_date2.striptags %}
    {{ field_date1 }}
{% else %}
    {{ field_date1 }} - {{ field_vegdate2 }}
{% endif %}

Or something like this...

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.