Drupal 9 date formats 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);