PHP 트레잇 Cake\Chronos\Traits\DifferenceTrait

Expects that the implementing class implements: - static::now() - static::instance() - copy()
파일 보기 프로젝트 열기: cakephp/chronos

보호된 프로퍼티들

프로퍼티 타입 설명
$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