How can I use 'xx time ago' as date format? How can I use 'xx time ago' for date format in Drupal 8 nodes ?

I want to replace "xx time ago" with {{ date }} in node.

In Drupal 7 it worked with this code :

&lt;?php
 print format_interval(time()-$node-&gt;created);
?&gt;
There are two ways to tackle this.
One is to just use the field formatters.  If you have a DateTime field, just goto Manage Display, and change the Format to Time ago.  Then click the gear, and pick some options.  These are cache aware that will bubble up through the page, but you may end up with short cache lifetimes in some situations.
The other is to use a template_preprocess_node().  This is preferable when you have a timestamp that isn't a field.  Then you use the date formatter service to render out the timestamp in timeago format.  It is preferable to use the formatDiff() versions rather than formatInterval() (while not formally deprecated, it is discouraged).
function MYTHEME_preprocess_node(&amp;$variables) {
  /** @var \Drupal\Core\Datetime\DateFormatterInterface $formatter */
  $date_formatter = \Drupal::service('date.formatter');
  $request_time = \Drupal::time()-&gt;getRequestTime();
  $variables['foo'] = $date_formatter-&gt;formatDiff($request_time - 12345, $request_time, [
    'granularity' =&gt; 3,
    'return_as_object' =&gt; TRUE,
  ])-&gt;toRenderable();
}

When you specify 'return_as_object' =&gt; TRUE with the formatDiff() functions, a FormattedDateDiff object gets returned, which contains the formatted string as well as a mostly accurate [#cache]['max-age'] entry in a render array to make this work with Drupal 8's new caching system.  Then you can just use {{ foo }} in your Twig template; the render engine will do the right thing with the render array instead of a plain string.
Also read the docs on DateFormatterInterface for the formatTimeDiffSince() and formatTimeDiffUntil() variants, and for the $options you can pass in.