class TimeImmutable extends DateTimeImmutable implements TimeInterface

Extension of the PHP DateTimeImmutable class.

Traits

Time trait.

Methods

__construct(string $time = 'now', DateTimeZone|string|null $timeZone = null)

Constructor.

from TimeTrait
static TimeTrait
now(DateTimeZone|string|null $timeZone = null)

Returns a new instance set to the current time.

from TimeTrait
static false|TimeTrait
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.

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

Returns a new instance according to the specified UNIX timestamp.

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

Returns a new instance according to the specified DOS timestamp.

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

Returns a new instance according to the specified time string.

from TimeTrait
false|static
setTimezone(DateTimeZone|string $timeZone)

No description

false|static
forward(int $seconds)

No description

false|static
rewind(int $seconds)

No description

int
getDOSTimestamp()

Returns the DOS timestamp.

from TimeTrait
bool
isLeapYear()

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

from TimeTrait
array
daysInMonths()

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

from TimeTrait
int
daysInMonth()

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

from TimeTrait
string
formatLocalized(string $format)

Returns a formatted date string according to current locale settings.

from TimeTrait
$this
copy()

Returns a copy of the current instance.

getMutable()

Returns a mutable instance of the current instance.

Details

in TimeTrait at line 28
__construct(string $time = 'now', DateTimeZone|string|null $timeZone = null)

Constructor.

Parameters

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

in TimeTrait at line 44
static TimeTrait 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

TimeTrait

in TimeTrait at line 58
static false|TimeTrait 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|TimeTrait

in TimeTrait at line 76
static false|TimeTrait 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|TimeTrait

in TimeTrait at line 88
static false|TimeTrait 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|TimeTrait

in TimeTrait at line 110
static false|TimeTrait 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|TimeTrait

at line 20
false|static setTimezone(DateTimeZone|string $timeZone)

Parameters

DateTimeZone|string $timeZone

Return Value

false|static

at line 20
false|static forward(int $seconds)

Parameters

int $seconds

Return Value

false|static

at line 20
false|static rewind(int $seconds)

Parameters

int $seconds

Return Value

false|static

in TimeTrait at line 172
int getDOSTimestamp()

Returns the DOS timestamp.

Return Value

int

in TimeTrait at line 194
bool isLeapYear()

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

Return Value

bool

in TimeTrait at line 211
array daysInMonths()

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

Return Value

array

in TimeTrait at line 235
int daysInMonth()

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

Return Value

int

in TimeTrait at line 246
string formatLocalized(string $format)

Returns a formatted date string according to current locale settings.

Parameters

string $format Date format

Return Value

string

at line 27
$this copy()

Returns a copy of the current instance.

Return Value

$this

at line 37
Time getMutable()

Returns a mutable instance of the current instance.

Return Value

Time