PHP Class Cake\Chronos\DifferenceFormatter

Provides a swappable component for other libraries to leverage. when localizing or customizing the difference output.
Show file Open project: cakephp/chronos

Public Methods

Method Description
__construct ( Translator | null $translate = null ) Constructor.
diffForHumans ( Cake\Chronos\ChronosInterface $date, Cake\Chronos\ChronosInterface $other = null, boolean $absolute = false ) : string Get the difference in a human readable format.

Method Details

__construct() public method

Constructor.
public __construct ( Translator | null $translate = null )
$translate Translator | null The text translator object.

diffForHumans() public method

Get the difference in a human readable format.
See also: Cake\Chronos\ChronosInterface::diffForHumans
public diffForHumans ( Cake\Chronos\ChronosInterface $date, Cake\Chronos\ChronosInterface $other = null, boolean $absolute = false ) : string
$date Cake\Chronos\ChronosInterface The datetime to start with.
$other Cake\Chronos\ChronosInterface The datetime to compare against.
$absolute boolean removes time difference modifiers ago, after, etc
return string The difference between the two days in a human readable format