1 common.inc format_time_diff_since($timestamp, $options = array())

Formats the time difference from a timestamp to the current request time.

@since 1.35.0 Function added.

Parameters

int $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 to format the date. Defaults to NULL, which results in the user interface language for the page being used.
  • strict: A Boolean value indicating whether or not the timestamp can be after the current request time. If TRUE (default) and $timestamp is after the current request time, the result string will be "0 seconds". If FALSE and $timestamp is after the current request time, the result string will be the formatted time difference.

Return value

string: A translated string representation of the difference between the given timestamp and the current request time. This interval is always positive.

See also

format_time_diff()

format_time_diff_until()

Related topics

File

core/includes/common.inc, line 2692
Common functions that many Backdrop modules will need to reference.

Code

function format_time_diff_since($timestamp, $options = array()) {
  return format_time_diff($timestamp, REQUEST_TIME, $options);
}