PRECISION_SECONDS
PRECISION_SECONDS
View helper to render a DateTime object as the amount of time elapsed since the DateTime. The precision of the elapsed time can be specified when the helper is invoked.
__invoke(\DateTimeInterface $datetime, string $precision = self::PRECISION_SECONDS, integer $range = 4) : string
Render a DateTime object as the elapsed time since the DateTime.
The precision of the elapsed time can be specified in two ways. The second parameter sets the minimum precision to days, hours, minutes or seconds (default).
$timeElapsed($datetime, 'hour'); Renders the number of days and hours since $datetime, but ignores minutes and seconds.
The third parameter sets the number of levels of precision that are rendered.
$timeElapased($datetime, 'second', 2); If the elapsed time is greater than 1 day it will render the number of days and hours. If it less than 1 day but greater than 1 hour it will render the number of hours and minutes.
\DateTimeInterface | $datetime | |
string | $precision | Minimum precision 'day' | 'hour' | 'minute' | 'second' |
integer | $range | Precision range |