public function DateFormatterInterface::formatInterval in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Datetime/DateFormatterInterface.php \Drupal\Core\Datetime\DateFormatterInterface::formatInterval()
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::formatDiff() instead.
Parameters
int $interval: The length of the interval in seconds.
int $granularity: (optional) How many different units to display in the string (2 by default).
string|null $langcode: (optional) langcode: The language code for the language used to format the date. Defaults to NULL, which results in the user interface language for the page being used.
Return value
string A translated string representation of the interval.
See also
\Drupal\Core\Datetime\DateFormatterInterface::formatDiff()
1 method overrides DateFormatterInterface::formatInterval()
- DateFormatter::formatInterval in core/
lib/ Drupal/ Core/ Datetime/ DateFormatter.php - Formats a time interval with the requested granularity.
File
- core/
lib/ Drupal/ Core/ Datetime/ DateFormatterInterface.php, line 66
Class
- DateFormatterInterface
- Provides an interface defining a date formatter.
Namespace
Drupal\Core\DatetimeCode
public function formatInterval($interval, $granularity = 2, $langcode = NULL);