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(DateTimeZone|string|null $timeZone = null)

Returns a new instance set to the current time.

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

Returns a new instance according to the specified date.

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

Returns a new instance according to the specified UNIX timestamp.

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

Returns a new instance according to the specified DOS timestamp.

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

Returns a new instance according to the specified time string.

$this
copy()

Returns a copy of the current instance.

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

Sets the time zone.

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

Move forward in time by x seconds.

$this|false|TimeInterface
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 65
static TimeInterface now(DateTimeZone|string|null $timeZone = null)

Returns a new instance set to the current time.

Parameters

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

Return Value

TimeInterface

at line 76
static false|TimeInterface createFromDate(int $year, int|null $month = null, int|null $day = null, DateTimeZone|string|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)
DateTimeZone|string|null $timeZone A valid time zone or a DateTimeZone object

Return Value

false|TimeInterface

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

Returns a new instance according to the specified UNIX timestamp.

Parameters

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

Return Value

false|TimeInterface

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

Returns a new instance according to the specified DOS timestamp.

Parameters

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

Return Value

false|TimeInterface

at line 104
static false|TimeInterface createFromFormat(string $format, string $time, DateTimeZone|string|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
DateTimeZone|string|null $timeZone A valid time zone or a DateTimeZone object

Return Value

false|TimeInterface

at line 111
$this copy()

Returns a copy of the current instance.

Return Value

$this

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

Sets the time zone.

Parameters

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

Return Value

$this|false|TimeInterface

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

Move forward in time by x seconds.

Parameters

int $seconds Number of seconds

Return Value

$this|false|TimeInterface

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

Move backward in time by x seconds.

Parameters

int $seconds Number of seconds

Return Value

$this|false|TimeInterface

at line 142
int getDOSTimestamp()

Returns the DOS timestamp.

Return Value

int

at line 149
bool isLeapYear()

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

Return Value

bool

at line 156
array daysInMonths()

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

Return Value

array

at line 163
int daysInMonth()

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

Return Value

int

at line 171
string formatLocalized(string $format)

Returns a formatted date string according to current locale settings.

Parameters

string $format Date format

Return Value

string