\Cake\ChronosDifferenceFormatter

Handles formatting differences in text.

Provides a swappable component for other libraries to leverage. when localizing or customizing the difference output.

Summary

Methods
Properties
Constants
__construct()
diffForHumans()
No public properties found
No constants found
No protected methods found
$translate
N/A
No private methods found
No private properties found
N/A

Properties

Methods

__construct()

__construct(\Cake\Chronos\Translator|null  $translate = null) 

Constructor.

Parameters

\Cake\Chronos\Translator|null $translate

The text translator object.

diffForHumans()

diffForHumans(\Cake\Chronos\ChronosInterface  $date, \Cake\Chronos\ChronosInterface|null  $other = null, boolean  $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

The datetime to compare against.

boolean $absolute

removes time difference modifiers ago, after, etc

Returns

string —

The difference between the two days in a human readable format