Class DifferenceFormatter
Handles formatting differences in text.
Provides a swappable component for other libraries to leverage. when localizing or customizing the difference output.
Namespace: Cake\Chronos
Property Summary
-
$translate protected
Cake\Chronos\Translator
The text translator object
Method Summary
-
__construct() public
Constructor.
-
diffForHumans() public
Get the difference in a human readable format.
Method Detail
__construct() ¶ public
__construct(Cake\Chronos\Translator|null $translate = null)
Constructor.
Parameters
-
Cake\Chronos\Translator|null
$translate optional The text translator object.
diffForHumans() ¶ public
diffForHumans(Cake\Chronos\ChronosInterface $date, Cake\Chronos\ChronosInterface|null $other = null, bool $absolute = false): string
Get the difference in a human readable format.
Parameters
-
Cake\Chronos\ChronosInterface
$date The datetime to start with.
-
Cake\Chronos\ChronosInterface|null
$other optional The datetime to compare against.
-
bool
$absolute optional removes time difference modifiers ago, after, etc
Returns
string
See Also
\Cake\Chronos\ChronosInterface::diffForHumans