PHP Трейт Cake\Chronos\Traits\DifferenceTrait

Expects that the implementing class implements: - static::now() - static::instance() - copy()
Показать файл Открыть проект

Защищенные свойства (Protected)

Свойство Тип Описание
$diffFormatter Cake\Chronos\DifferenceFormatter Instance of the diff formatting object.

Открытые методы

Метод Описание
diffFiltered ( ChronosInterval $ci, callable $callback, Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer Get the difference by the given interval using a filter callable
diffForHumans ( Cake\Chronos\ChronosInterface $other = null, boolean $absolute = false ) : string Get the difference in a human readable format.
diffFormatter ( DifferenceFormatter | null $formatter = null ) : DifferenceFormatter Get the difference formatter instance or overwrite the current one.
diffInDays ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer Get the difference in days
diffInDaysFiltered ( callable $callback, Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer Get the difference in days using a filter callable
diffInHours ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer Get the difference in hours
diffInHoursFiltered ( callable $callback, Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer Get the difference in hours using a filter callable
diffInMinutes ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer Get the difference in minutes
diffInMonths ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer Get the difference in months
diffInSeconds ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer Get the difference in seconds
diffInWeekdays ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer Get the difference in weekdays
diffInWeekendDays ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer Get the difference in weekend days using a filter
diffInWeeks ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer Get the difference in weeks
diffInYears ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer Get the difference in years
fromNow ( DateTime | DateTimeImmutable $datetime ) : DateInterval | boolean Convenience method for getting the remaining time from a given time.
secondsSinceMidnight ( ) : integer The number of seconds since midnight.
secondsUntilEndOfDay ( ) : integer The number of seconds until 23:23:59.

Описание методов

diffFiltered() публичный Метод

Get the difference by the given interval using a filter callable
public diffFiltered ( ChronosInterval $ci, callable $callback, Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer
$ci Cake\Chronos\ChronosInterval An interval to traverse by
$callback callable The callback to use for filtering.
$dt Cake\Chronos\ChronosInterface The instance to difference from.
$abs boolean Get the absolute of the difference
Результат integer

diffForHumans() публичный Метод

When comparing a value in the past to default now: 1 hour ago 5 months ago When comparing a value in the future to default now: 1 hour from now 5 months from now When comparing a value in the past to another value: 1 hour before 5 months before When comparing a value in the future to another value: 1 hour after 5 months after
public diffForHumans ( Cake\Chronos\ChronosInterface $other = null, boolean $absolute = false ) : string
$other Cake\Chronos\ChronosInterface The datetime to compare with.
$absolute boolean removes time difference modifiers ago, after, etc
Результат string

diffFormatter() публичный статический Метод

Get the difference formatter instance or overwrite the current one.
public static diffFormatter ( DifferenceFormatter | null $formatter = null ) : DifferenceFormatter
$formatter Cake\Chronos\DifferenceFormatter | null The formatter instance when setting.
Результат Cake\Chronos\DifferenceFormatter The formatter instance.

diffInDays() публичный Метод

Get the difference in days
public diffInDays ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer
$dt Cake\Chronos\ChronosInterface The instance to difference from.
$abs boolean Get the absolute of the difference
Результат integer

diffInDaysFiltered() публичный Метод

Get the difference in days using a filter callable
public diffInDaysFiltered ( callable $callback, Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer
$callback callable The callback to use for filtering.
$dt Cake\Chronos\ChronosInterface The instance to difference from.
$abs boolean Get the absolute of the difference
Результат integer

diffInHours() публичный Метод

Get the difference in hours
public diffInHours ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer
$dt Cake\Chronos\ChronosInterface The instance to difference from.
$abs boolean Get the absolute of the difference
Результат integer

diffInHoursFiltered() публичный Метод

Get the difference in hours using a filter callable
public diffInHoursFiltered ( callable $callback, Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer
$callback callable The callback to use for filtering.
$dt Cake\Chronos\ChronosInterface The instance to difference from.
$abs boolean Get the absolute of the difference
Результат integer

diffInMinutes() публичный Метод

Get the difference in minutes
public diffInMinutes ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer
$dt Cake\Chronos\ChronosInterface The instance to difference from.
$abs boolean Get the absolute of the difference
Результат integer

diffInMonths() публичный Метод

Get the difference in months
public diffInMonths ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer
$dt Cake\Chronos\ChronosInterface The instance to difference from.
$abs boolean Get the absolute of the difference
Результат integer

diffInSeconds() публичный Метод

Get the difference in seconds
public diffInSeconds ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer
$dt Cake\Chronos\ChronosInterface The instance to difference from.
$abs boolean Get the absolute of the difference
Результат integer

diffInWeekdays() публичный Метод

Get the difference in weekdays
public diffInWeekdays ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer
$dt Cake\Chronos\ChronosInterface The instance to difference from.
$abs boolean Get the absolute of the difference
Результат integer

diffInWeekendDays() публичный Метод

Get the difference in weekend days using a filter
public diffInWeekendDays ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer
$dt Cake\Chronos\ChronosInterface The instance to difference from.
$abs boolean Get the absolute of the difference
Результат integer

diffInWeeks() публичный Метод

Get the difference in weeks
public diffInWeeks ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer
$dt Cake\Chronos\ChronosInterface The instance to difference from.
$abs boolean Get the absolute of the difference
Результат integer

diffInYears() публичный Метод

Get the difference in years
public diffInYears ( Cake\Chronos\ChronosInterface $dt = null, boolean $abs = true ) : integer
$dt Cake\Chronos\ChronosInterface The instance to difference from.
$abs boolean Get the absolute of the difference
Результат integer

fromNow() публичный статический Метод

Convenience method for getting the remaining time from a given time.
public static fromNow ( DateTime | DateTimeImmutable $datetime ) : DateInterval | boolean
$datetime DateTime | DateTimeImmutable The date to get the remaining time from.
Результат DateInterval | boolean The DateInterval object representing the difference between the two dates or FALSE on failure.

secondsSinceMidnight() публичный Метод

The number of seconds since midnight.
public secondsSinceMidnight ( ) : integer
Результат integer

secondsUntilEndOfDay() публичный Метод

The number of seconds until 23:23:59.
public secondsUntilEndOfDay ( ) : integer
Результат integer

Описание свойств

$diffFormatter защищенное статическое свойство

Instance of the diff formatting object.
protected static DifferenceFormatter,Cake\Chronos $diffFormatter
Результат Cake\Chronos\DifferenceFormatter