public DateFormatterInterface::formatInterval($interval, $granularity = 2, $langcode = NULL)
Formats a time interval with the requested granularity.
Note that for intervals over 30 days, the output is approximate: a "month" is always exactly 30 days, and a "year" is always 365 days. It is not possible to make a more exact representation, given that there is only one input in seconds. If you are formatting an interval between two specific timestamps, use \Drupal\Core\Datetime\DateFormatter::form