PHP Trait Cake\Chronos\Traits\DifferenceTrait

Expects that the implementing class implements: - static::now() - static::instance() - copy()
Afficher le fichier Open project: cakephp/chronos

Protected Properties

Свойство Type Description
$diffFormatter Cake\Chronos\DifferenceFormatter Instance of the diff formatting object.

Méthodes publiques

Méthode Description
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.

Method Details

diffFiltered() public méthode

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
Résultat integer

diffForHumans() public méthode

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
Résultat string

diffFormatter() public static méthode

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.
Résultat Cake\Chronos\DifferenceFormatter The formatter instance.

diffInDays() public méthode

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
Résultat integer

diffInDaysFiltered() public méthode

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
Résultat integer

diffInHours() public méthode

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
Résultat integer

diffInHoursFiltered() public méthode

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
Résultat integer

diffInMinutes() public méthode

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
Résultat integer

diffInMonths() public méthode

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
Résultat integer

diffInSeconds() public méthode

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
Résultat integer

diffInWeekdays() public méthode

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
Résultat integer

diffInWeekendDays() public méthode

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
Résultat integer

diffInWeeks() public méthode

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
Résultat integer

diffInYears() public méthode

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
Résultat integer

fromNow() public static méthode

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.
Résultat DateInterval | boolean The DateInterval object representing the difference between the two dates or FALSE on failure.

secondsSinceMidnight() public méthode

The number of seconds since midnight.
public secondsSinceMidnight ( ) : integer
Résultat integer

secondsUntilEndOfDay() public méthode

The number of seconds until 23:23:59.
public secondsUntilEndOfDay ( ) : integer
Résultat integer

Property Details

$diffFormatter protected_oe static_oe property

Instance of the diff formatting object.
protected static DifferenceFormatter,Cake\Chronos $diffFormatter
Résultat Cake\Chronos\DifferenceFormatter