CodeIgniter v4.5 API

TimeDifference
in package

Class TimeDifference

Tags
see
TimeDifferenceTest

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

$testTime

The timestamp to compare the current time to.

protected float $testTime

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
bool

getDays()

Returns the number of days difference between the two dates.

public getDays([bool $raw = false ]) : float|int
Parameters
$raw : bool = false
Return values
float|int

getHours()

Returns the number of hours difference between the two dates.

public getHours([bool $raw = false ]) : float|int
Parameters
$raw : bool = false
Return values
float|int

getMinutes()

Returns the number of minutes difference between the two dates.

public getMinutes([bool $raw = false ]) : float|int
Parameters
$raw : bool = false
Return values
float|int

getMonths()

Returns the number of months difference between the two dates.

public getMonths([bool $raw = false ]) : float|int
Parameters
$raw : bool = false
Return values
float|int

getSeconds()

Returns the number of seconds difference between the two dates.

public getSeconds([bool $raw = false ]) : int
Parameters
$raw : bool = false
Return values
int

getWeeks()

Returns the number of weeks difference between the two dates.

public getWeeks([bool $raw = false ]) : float|int
Parameters
$raw : bool = false
Return values
float|int

getYears()

Returns the number of years of difference between the two.

public getYears([bool $raw = false ]) : float|int
Parameters
$raw : bool = false
Return values
float|int

humanize()

Convert the time to human readable format

public humanize([string|null $locale = null ]) : string
Parameters
$locale : string|null = null
Return values
string

        
On this page

Search results