TimeDifference
in package
Class TimeDifference
Tags
Table of Contents
Properties
- $currentTime : IntlCalendar
- The timestamp of the "current" time.
- $days : int
- Days.
- $difference : int
- Difference in seconds.
- $eras : float
- Eras.
- $hours : int
- Hours.
- $minutes : int
- Minutes.
- $months : float
- Months.
- $seconds : int
- Seconds.
- $testTime : float
- The timestamp to compare the current time to.
- $weeks : int
- Weeks.
- $years : float
- Years.
Methods
- __construct() : mixed
- Note: both parameters are required to be in the same timezone. No timezone shifting is done internally.
- __get() : float|int|null
- Allow property-like access to our calculated values.
- __isset() : bool
- Allow property-like checking for our calculated values.
- getDays() : float|int
- Returns the number of days difference between the two dates.
- getHours() : float|int
- Returns the number of hours difference between the two dates.
- getMinutes() : float|int
- Returns the number of minutes difference between the two dates.
- getMonths() : float|int
- Returns the number of months difference between the two dates.
- getSeconds() : int
- Returns the number of seconds difference between the two dates.
- getWeeks() : float|int
- Returns the number of weeks difference between the two dates.
- getYears() : float|int
- Returns the number of years of difference between the two.
- humanize() : string
- Convert the time to human readable format
Properties
$currentTime
The timestamp of the "current" time.
protected
IntlCalendar
$currentTime
$days
Days.
protected
int
$days
= 0
$difference
Difference in seconds.
protected
int
$difference
$eras
Eras.
protected
float
$eras
= 0
$hours
Hours.
protected
int
$hours
= 0
$minutes
Minutes.
protected
int
$minutes
= 0
$months
Months.
protected
float
$months
= 0
$seconds
Seconds.
protected
int
$seconds
= 0
$testTime
The timestamp to compare the current time to.
protected
float
$testTime
$weeks
Weeks.
protected
int
$weeks
= 0
$years
Years.
protected
float
$years
= 0
Methods
__construct()
Note: both parameters are required to be in the same timezone. No timezone shifting is done internally.
public
__construct(DateTime $currentTime, DateTime $testTime) : mixed
Parameters
- $currentTime : DateTime
- $testTime : DateTime
__get()
Allow property-like access to our calculated values.
public
__get(string $name) : float|int|null
Parameters
- $name : string
Return values
float|int|null__isset()
Allow property-like checking for our calculated values.
public
__isset(string $name) : bool
Parameters
- $name : string
Return values
boolgetDays()
Returns the number of days difference between the two dates.
public
getDays([bool $raw = false ]) : float|int
Parameters
- $raw : bool = false
Return values
float|intgetHours()
Returns the number of hours difference between the two dates.
public
getHours([bool $raw = false ]) : float|int
Parameters
- $raw : bool = false
Return values
float|intgetMinutes()
Returns the number of minutes difference between the two dates.
public
getMinutes([bool $raw = false ]) : float|int
Parameters
- $raw : bool = false
Return values
float|intgetMonths()
Returns the number of months difference between the two dates.
public
getMonths([bool $raw = false ]) : float|int
Parameters
- $raw : bool = false
Return values
float|intgetSeconds()
Returns the number of seconds difference between the two dates.
public
getSeconds([bool $raw = false ]) : int
Parameters
- $raw : bool = false
Return values
intgetWeeks()
Returns the number of weeks difference between the two dates.
public
getWeeks([bool $raw = false ]) : float|int
Parameters
- $raw : bool = false
Return values
float|intgetYears()
Returns the number of years of difference between the two.
public
getYears([bool $raw = false ]) : float|int
Parameters
- $raw : bool = false
Return values
float|inthumanize()
Convert the time to human readable format
public
humanize([string|null $locale = null ]) : string
Parameters
- $locale : string|null = null