Make a custom date formatter for view Looking for a way to add my own date formatter in view. Actualy have the "default" and "Time ago" one, but I want to had another one to display date has FB do in the notification feed :

For today notification : Today, 09:33

For Yesterday notification : Yesterday, 10:36

For this week notification (except today and yesterday) : Mon. 06:34

All other notification : 09/12/17, 15:59

Is this possible ? Or maybe in an other way than add something in view module ?

Working on Drupal 8.2.0 version.
In Drupal 8, views field output uses the field formatters that entities use (Drupal 7 uses its own plugins for this).

The "Today", "Yesterday", "Monday", other functionality cannot be handled by the standard field formatters.

Drupal 8 makes it easy, though, to make new formatters.  Make a custom module, and extend DateTimeDefaultFormatter.  Inside this class, you would override the formatDate() method (and possible the defaultSettings() one, depending on how fancy you want to be.  The method would look something like this

protected function formatDate() {
  $timezone = $this-&gt;getSetting('timezone_override') ?: $date-&gt;getTimezone()-&gt;getName();

  if ($date is today) {
    $output = $this-&gt;t('Today, @formatted', [
      '@formatted' =&gt; $this-&gt;dateFormatter-&gt;format($date-&gt;getTimestamp(), 'custom', 'H:i', $timezone != '' ? $timezone : NULL);
    ]),
  }
  else if ($date is yesterday) {
    $output = $this-&gt;t('Yesterday, @formatted', [
      '@formatted' =&gt; $this-&gt;dateFormatter-&gt;format($date-&gt;getTimestamp(), 'custom', 'H:i', $timezone != '' ? $timezone : NULL);
    ]),
  }
  else if ($date is this week) {
    $output = $this-&gt;dateFormatter-&gt;format($date-&gt;getTimestamp(), 'custom', 'D. H:i', $timezone != '' ? $timezone : NULL);
  }
  else {
    $output = $this-&gt;dateFormatter-&gt;format($date-&gt;getTimestamp(), 'custom', 'm/d/y H:i', $timezone != '' ? $timezone : NULL);
  }

  return $output;
}


You need to work out the logic to choose the proper format.  Set the annotation on the formatter properly, and you can use this formatter in the view (or anywhere else).

This should give you a start.