DifferenceFormatter
in package
implements
DifferenceFormatterInterface
Handles formatting differences in text.
Provides a swappable component for other libraries to leverage. when localizing or customizing the difference output.
Table of Contents
Interfaces
- DifferenceFormatterInterface
- Interface for formatting differences in text.
Properties
- $translate : Translator
- The text translator object
Methods
- __construct() : mixed
- Constructor.
- diffForHumans() : string
- Get the difference in a human readable format.
Properties
$translate
The text translator object
protected
Translator
$translate
Methods
__construct()
Constructor.
public
__construct([Translator|null $translate = null ]) : mixed
Parameters
- $translate : Translator|null = null
-
The text translator object.
diffForHumans()
Get the difference in a human readable format.
public
diffForHumans(ChronosInterface $date[, ChronosInterface|null $other = null ][, bool $absolute = false ]) : string
Parameters
- $date : ChronosInterface
-
The datetime to start with.
- $other : ChronosInterface|null = null
-
The datetime to compare against.
- $absolute : bool = false
-
removes time difference modifiers ago, after, etc
Tags
Return values
string —The difference between the two days in a human readable format