Time
in package
implements
TimeInterface
A class to represent amounts of time.
Table of Contents
Interfaces
- TimeInterface
- A class to represent amounts of time.
Properties
- $seconds : int
Methods
- __toString() : string
- Get the time in the format hh:mm:ss.
- asInt() : int
- Get the number of seconds this instance represents.
- asString() : string
- Get the time in the format hh:mm:ss.
- format() : string
- Format the time in a custom way.
- fromFormat() : TimeInterface
- Create a new instance from a time in a specified format.
- getHours() : int
- Get the hours portion of the time.
- getMinutes() : int
- Get the minutes portion of the time.
- getSeconds() : int
- Get the seconds portion of the time.
- inSeconds() : TimeInterface
- Create a new instance from a number of seconds.
- parse() : TimeInterface
- Create a new instance from a time in the format hh:mm:ss.
- start() : TimeInterface
- Create a new time instance representing the start.
- __construct() : mixed
- Create a new instance from a number of seconds.
Properties
$seconds
private
int
$seconds
= 0
Methods
__toString()
Get the time in the format hh:mm:ss.
public
__toString() : string
Return values
stringasInt()
Get the number of seconds this instance represents.
public
asInt() : int
Return values
intasString()
Get the time in the format hh:mm:ss.
public
asString() : string
Return values
stringformat()
Format the time in a custom way.
public
format(string $format) : string
Parameters
- $format : string
-
The custom format to use. %h, %m, %s are available, and uppercase versions (%H, %M, %S) ensure a leading zero is present for single digit values
Return values
stringfromFormat()
Create a new instance from a time in a specified format.
public
static fromFormat(string $format, string $string) : TimeInterface
Parameters
- $format : string
-
The format the string is in (using %h, %m, %s as placeholders)
- $string : string
-
The time to parse
Return values
TimeInterfacegetHours()
Get the hours portion of the time.
public
getHours() : int
Return values
intgetMinutes()
Get the minutes portion of the time.
public
getMinutes() : int
Return values
intgetSeconds()
Get the seconds portion of the time.
public
getSeconds() : int
Return values
intinSeconds()
Create a new instance from a number of seconds.
public
static inSeconds(int $seconds) : TimeInterface
Parameters
- $seconds : int
Return values
TimeInterfaceparse()
Create a new instance from a time in the format hh:mm:ss.
public
static parse(string $string) : TimeInterface
Parameters
- $string : string
Return values
TimeInterfacestart()
Create a new time instance representing the start.
public
static start() : TimeInterface
Return values
TimeInterface__construct()
Create a new instance from a number of seconds.
private
__construct(int $seconds) : mixed
Parameters
- $seconds : int
-
The number of seconds