Class RelativeTimeFormatter
Helper class for formatting relative dates & times.
Method Summary
Method Detail
_diffData() protected
_diffData(mixed $futureTime, mixed $pastTime, bool $backwards, mixed $options)
Calculate the data needed to format a relative difference string.
Parameters
-
int|string$futureTime The timestamp from the future.
-
int|string$pastTime The timestamp from the past.
-
bool$backwards Whether or not the difference was backwards.
-
array$options An array of options.
Returns
arrayAn array of values.
_options() protected
_options(array $options, string $class)
Build the options for relative date formatting.
Parameters
-
array$options The options provided by the user.
-
string$class The class name to use for defaults.
Returns
arrayOptions with defaults applied.
dateAgoInWords() public
dateAgoInWords(\Cake\I18n\I18nDateTimeInterface $date, array $options)
Format a into a relative date string.
Parameters
-
\Cake\I18n\I18nDateTimeInterface$date The date to format.
-
array$options optional Array of options.
Returns
stringRelative date string.
See Also
diffForHumans() public
diffForHumans(\Cake\Chronos\ChronosInterface $date, ?\Cake\Chronos\ChronosInterface $other, bool $absolute)
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
stringThe difference between the two days in a human readable format.
See Also
timeAgoInWords() public
timeAgoInWords(\Cake\I18n\I18nDateTimeInterface $time, array $options)
Format a into a relative timestring.
Parameters
-
\Cake\I18n\I18nDateTimeInterface$time The time instance to format.
-
array$options optional Array of options.
Returns
stringRelative time string.
See Also
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.1/class-Cake.I18n.RelativeTimeFormatter.html