drupal 8 date formatter service code example
Example: drupal 8 date formater service
\Drupal::service('date.formatter')
->format($timestamp, $type, $format, $timezone, $langcode);
\Drupal::service('date.formatter')
->format($timestamp, $type, $format, $timezone, $langcode);