How can I display the time passed since a comment was created instead of the creation date? how to personalize my comments ?


I want to display since when the comment was created instead of the date.
I want to display the comment ID with the link "permalink".


Can you help me ? Thank you

comment--field-article-commentaire.html.twig :

&lt;article{{ attributes.addClass('js-comment comment--field-article-commentaire') }}&gt;
  &lt;div class="row card rounded-lg mt-4"&gt;
    &lt;div class="card-header p-2 m-0 h6"&gt;
      &lt;div class="media"&gt;
        &lt;div class="timeline-icon mt-1 mr-3 mb-1 ml-1 float-left"&gt;
          {{ drupal_entity('user', comment.uid.target_id, 'comment') }}
        &lt;/div&gt;
        &lt;div class="media-body"&gt;
          &lt;div class="mb-2"&gt;
            {{ permalink }}
          &lt;/div&gt;
          &lt;div class="mb-2"&gt;
            {{ author }}
          &lt;/div&gt;
          &lt;div class="mb-0"&gt;
            le {{ created }}
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="card-body p-2"&gt;
      {{ content.field_article_commentaire }}
    &lt;/div&gt;
    &lt;div class="card-footer d-flex flex-wrap justify-content-start pt-0"&gt;
      &lt;div class="mt-3 mr-3"&gt;
        {{ content.flag_report_comment }}
      &lt;/div&gt;
      &lt;div class="mt-3 mr-3"&gt;
        {{ content.links }}
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/article&gt;


Here is the current view of my comments :

https://ibb.co/QF051yV

I would like to display the date like this :

https://ibb.co/QCQbmG2
Twig's date extension does exactly what you ask:

{{ created | time_diff }}


However, this extension isn't in Drupal by default, assuming you're using Composer you need to add this extension to your project by running:

composer require twig/extensions