DateFormatterInterface::formatDiff

public DateFormatterInterface::formatDiff($from, $to, $options = array()) Formats a time interval between two timestamps. Parameters int $from: A UNIX timestamp, defining the from date and time. int $to: A UNIX timestamp, defining the to date and time. array $options: (optional) An associative array with additional options. The following keys can be used: granularity: An integer value that signals how many different units to display in the string. Defaults to 2. langcode: The language code f

DateFormatterInterface::format

public DateFormatterInterface::format($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) Formats a date, using a date type or a custom date format string. Parameters int $timestamp: A UNIX timestamp to format. string $type: (optional) The format to use, one of: One of the built-in formats: 'short', 'medium', 'long', 'html_datetime', 'html_date', 'html_time', 'html_yearless_date', 'html_week', 'html_month', 'html_year'. The name of a date type defined by a date for

DateFormatterInterface

Provides an interface defining a date formatter. Hierarchy interface \Drupal\Core\Datetime\DateFormatterInterface File core/lib/Drupal/Core/Datetime/DateFormatterInterface.php, line 8 Namespace Drupal\Core\Datetime Members Name Modifiers Type Description DateFormatterInterface::format public function Formats a date, using a date type or a custom date format string. DateFormatterInterface::formatDiff public function Formats a time interval between two timestamps.

DateFormatter::__construct

public DateFormatter::__construct(EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, TranslationInterface $translation, ConfigFactoryInterface $config_factory, RequestStack $request_stack) Constructs a Date object. Parameters \Drupal\Core\Entity\EntityManagerInterface $entity_manager: The entity manager. \Drupal\Core\Language\LanguageManagerInterface $language_manager: The language manager. \Drupal\Core\StringTranslation\TranslationInterface $translation: The s

DateFormatter::getSampleDateFormats

public DateFormatter::getSampleDateFormats($langcode = NULL, $timestamp = NULL, $timezone = NULL) Provides values for all date formatting characters for a given timestamp. Parameters string|null $langcode: (optional) Language code of the date format, if different from the site default language. int|null $timestamp: (optional) The Unix timestamp to format, defaults to current time. string|null $timezone: (optional) The timezone to use, if different from the site's default timezone. Return value

DateFormatter::formatTimeDiffUntil

public DateFormatter::formatTimeDiffUntil($timestamp, $options = array()) Formats the time difference from the current request time to a timestamp. Parameters $timestamp: A UNIX timestamp to compare against the current request time. array $options: (optional) An associative array with additional options. The following keys can be used: granularity: An integer value that signals how many different units to display in the string. Defaults to 2. langcode: The language code for the language used

DateFormatter::formatTimeDiffSince

public DateFormatter::formatTimeDiffSince($timestamp, $options = array()) Formats the time difference from a timestamp to the current request time. Parameters $timestamp: A UNIX timestamp to compare against the current request time. array $options: (optional) An associative array with additional options. The following keys can be used: granularity: An integer value that signals how many different units to display in the string. Defaults to 2. langcode: The language code for the language used

DateFormatter::formatInterval

public DateFormatter::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::formatDiff()

DateFormatter::formatDiff

public DateFormatter::formatDiff($from, $to, $options = array()) Formats a time interval between two timestamps. Parameters int $from: A UNIX timestamp, defining the from date and time. int $to: A UNIX timestamp, defining the to date and time. array $options: (optional) An associative array with additional options. The following keys can be used: granularity: An integer value that signals how many different units to display in the string. Defaults to 2. langcode: The language code for the la

DateFormatter::format

public DateFormatter::format($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) Formats a date, using a date type or a custom date format string. Parameters int $timestamp: A UNIX timestamp to format. string $type: (optional) The format to use, one of: One of the built-in formats: 'short', 'medium', 'long', 'html_datetime', 'html_date', 'html_time', 'html_yearless_date', 'html_week', 'html_month', 'html_year'. The name of a date type defined by a date format confi