Helper class for formatting relative dates & times.
Calculate the data needed to format a relative difference string.
Build the options for relative date formatting.
Format a into a relative date string.
Get the difference in a human readable format.
Format a into a relative timestring.
_diffData(string|int $futureTime, string|int $pastTime, bool $backwards, array<string, mixed> $options): array
Calculate the data needed to format a relative difference string.
string|int
$futureTime The timestamp from the future.
string|int
$pastTime The timestamp from the past.
bool
$backwards Whether the difference was backwards.
array<string, mixed>
$options An array of options.
array
_options(array<string, mixed> $options, string $class): array<string, mixed>
Build the options for relative date formatting.
array<string, mixed>
$options The options provided by the user.
string
$class The class name to use for defaults.
array<string, mixed>
dateAgoInWords(Cake\I18n\I18nDateTimeInterface $date, array<string, mixed> $options = []): string
Format a into a relative date string.
Cake\I18n\I18nDateTimeInterface
$date The date to format.
array<string, mixed>
$options optional Array of options.
string
diffForHumans(Cake\Chronos\ChronosInterface $date, Cake\Chronos\ChronosInterface|null $other = null, bool $absolute = false): string
Get the difference in a human readable format.
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.
string
timeAgoInWords(Cake\I18n\I18nDateTimeInterface $time, array<string, mixed> $options = []): string
Format a into a relative timestring.
Cake\I18n\I18nDateTimeInterface
$time The time instance to format.
array<string, mixed>
$options optional Array of options.
string
© 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.4/class-Cake.I18n.RelativeTimeFormatter.html