class TimeImmutable extends DateTimeImmutable implements TimeInterface

Extension of the PHP DateTimeImmutable class.

Traits

Methods

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

Constructor.

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

Returns a new instance set to the current time.

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

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

Returns a new instance according to the specified UNIX timestamp.

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

Returns a new instance according to the specified DOS timestamp.

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

Returns a new instance according to the specified time string.

from TimeTrait
static|false
setTimezone(DateTimeZone $timeZone)

No description

static|false
forward()

No description

static|false
rewind()

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 20
__construct(string $time = 'now', string|DateTimeZone|null $timeZone = null)

Constructor.

Parameters

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

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

TimeTrait

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

TimeTrait|false

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

TimeTrait|false

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

TimeTrait|false

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

TimeTrait|false

at line 22
static|false setTimezone(DateTimeZone $timeZone)

Parameters

DateTimeZone $timeZone

Return Value

static|false

at line 22
static|false forward()

Return Value

static|false

at line 22
static|false rewind()

Return Value

static|false

in TimeTrait at line 164
int getDOSTimestamp()

Returns the DOS timestamp.

Return Value

int

in TimeTrait at line 186
bool isLeapYear()

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

Return Value

bool

in TimeTrait at line 203
array daysInMonths()

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

Return Value

array

in TimeTrait at line 227
int daysInMonth()

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

Return Value

int

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

Returns a formatted date string according to current locale settings.

Parameters

string $format Date format

Return Value

string

at line 29
$this copy()

Returns a copy of the current instance.

Return Value

$this

at line 39
Time getMutable()

Returns a mutable instance of the current instance.

Return Value

Time