Documentation

Time
in package
implements TimeInterface

FinalYes

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
string

asInt()

Get the number of seconds this instance represents.

public asInt() : int
Return values
int

asString()

Get the time in the format hh:mm:ss.

public asString() : string
Return values
string

format()

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
string

fromFormat()

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
TimeInterface

getHours()

Get the hours portion of the time.

public getHours() : int
Return values
int

getMinutes()

Get the minutes portion of the time.

public getMinutes() : int
Return values
int

getSeconds()

Get the seconds portion of the time.

public getSeconds() : int
Return values
int

inSeconds()

Create a new instance from a number of seconds.

public static inSeconds(int $seconds) : TimeInterface
Parameters
$seconds : int
Return values
TimeInterface

parse()

Create a new instance from a time in the format hh:mm:ss.

public static parse(string $string) : TimeInterface
Parameters
$string : string
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

On this page

Search results