PHP Trait Cake\Chronos\Traits\DifferenceTrait

Expects that the implementing class implements: - static::now() - static::instance() - copy()
Datei anzeigen Open project: cakephp/chronos

Protected Properties

Property Type Description
$diffFormatter Cake\Chronos\DifferenceFormatter Instance of the diff formatting object.

Public Methods

Method 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 method

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
return integer

diffForHumans() public method

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
return string

diffFormatter() public static method

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

diffInDays() public method

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
return integer

diffInDaysFiltered() public method

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
return integer

diffInHours() public method

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
return integer

diffInHoursFiltered() public method

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
return integer

diffInMinutes() public method

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
return integer

diffInMonths() public method

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
return integer

diffInSeconds() public method

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
return integer

diffInWeekdays() public method

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
return integer

diffInWeekendDays() public method

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
return integer

diffInWeeks() public method

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
return integer

diffInYears() public method

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
return integer

fromNow() public static method

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

secondsSinceMidnight() public method

The number of seconds since midnight.
public secondsSinceMidnight ( ) : integer
return integer

secondsUntilEndOfDay() public method

The number of seconds until 23:23:59.
public secondsUntilEndOfDay ( ) : integer
return integer

Property Details

$diffFormatter protected_oe static_oe property

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