interface TimeInterface implements DateTimeInterface

Time interface.

Constants

MINUTE

Number of seconds in a minute.

HOUR

Number of seconds in an hour.

DAY

Number of seconds in a day.

WEEK

Number of seconds in a week.

MONTH

Average number of seconds in a month.

YEAR

Average number of seconds in a year.

Methods

static TimeInterface
now(string|DateTimeZone|null $timeZone = null)

Returns a new instance set to the current time.

static TimeInterface|false
createFromDate(int $year, int|null $month = null, int|null $day = null, string|DateTimeZone|null $timeZone = null)

Returns a new instance according to the specified date.

static TimeInterface|false
createFromTimestamp(int $timestamp, string|DateTimeZone|null $timeZone = null)

Returns a new instance according to the specified UNIX timestamp.

static TimeInterface|false
createFromDOSTimestamp(int $timestamp, string|DateTimeZone|null $timeZone = null)

Returns a new instance according to the specified DOS timestamp.

static TimeInterface|false
createFromFormat(string $format, string $time, string|DateTimeZone|null $timeZone = null)

Returns a new instance according to the specified time string.

$this
copy()

Returns a copy of the current instance.

$this|TimeInterface|false
setTimezone(string|DateTimeZone $timeZone)

Sets the time zone.

$this|TimeInterface|false
forward(int $seconds)

Move forward in time by x seconds.

$this|TimeInterface|false
rewind(int $seconds)

Move backward in time by x seconds.

int
getDOSTimestamp()

Returns the DOS timestamp.

bool
isLeapYear()

Returns TRUE if the year is a leap year and FALSE if not.

array
daysInMonths()

Returns an array containing the number of days in each month of the year.

int
daysInMonth()

Returns the number of days in the current or specified month.

string
formatLocalized(string $format)

Returns a formatted date string according to current locale settings.

Details

at line 67
static TimeInterface now(string|DateTimeZone|null $timeZone = null)

Returns a new instance set to the current time.

Parameters

string|DateTimeZone|null $timeZone A valid time zone or a DateTimeZone object

Return Value

TimeInterface

at line 78
static TimeInterface|false createFromDate(int $year, int|null $month = null, int|null $day = null, string|DateTimeZone|null $timeZone = null)

Returns a new instance according to the specified date.

Parameters

int $year Year
int|null $month Month (1 to 12)
int|null $day Day of month (1 to 31)
string|DateTimeZone|null $timeZone A valid time zone or a DateTimeZone object

Return Value

TimeInterface|false

at line 87
static TimeInterface|false createFromTimestamp(int $timestamp, string|DateTimeZone|null $timeZone = null)

Returns a new instance according to the specified UNIX timestamp.

Parameters

int $timestamp UNIX timestamp
string|DateTimeZone|null $timeZone A valid time zone or a DateTimeZone object

Return Value

TimeInterface|false

at line 96
static TimeInterface|false createFromDOSTimestamp(int $timestamp, string|DateTimeZone|null $timeZone = null)

Returns a new instance according to the specified DOS timestamp.

Parameters

int $timestamp DOS timestamp
string|DateTimeZone|null $timeZone A valid time zone or a DateTimeZone object

Return Value

TimeInterface|false

at line 106
static TimeInterface|false createFromFormat(string $format, string $time, string|DateTimeZone|null $timeZone = null)

Returns a new instance according to the specified time string.

Parameters

string $format The format that the passed in string should be in
string $time String representing the time
string|DateTimeZone|null $timeZone A valid time zone or a DateTimeZone object

Return Value

TimeInterface|false

at line 113
$this copy()

Returns a copy of the current instance.

Return Value

$this

at line 121
$this|TimeInterface|false setTimezone(string|DateTimeZone $timeZone)

Sets the time zone.

Parameters

string|DateTimeZone $timeZone A valid time zone or a DateTimeZone object

Return Value

$this|TimeInterface|false

at line 129
$this|TimeInterface|false forward(int $seconds)

Move forward in time by x seconds.

Parameters

int $seconds Number of seconds

Return Value

$this|TimeInterface|false

at line 137
$this|TimeInterface|false rewind(int $seconds)

Move backward in time by x seconds.

Parameters

int $seconds Number of seconds

Return Value

$this|TimeInterface|false

at line 144
int getDOSTimestamp()

Returns the DOS timestamp.

Return Value

int

at line 151
bool isLeapYear()

Returns TRUE if the year is a leap year and FALSE if not.

Return Value

bool

at line 158
array daysInMonths()

Returns an array containing the number of days in each month of the year.

Return Value

array

at line 165
int daysInMonth()

Returns the number of days in the current or specified month.

Return Value

int

at line 173
string formatLocalized(string $format)

Returns a formatted date string according to current locale settings.

Parameters

string $format Date format

Return Value

string