class DateTime extends DateTime implements JsonSerializable

DateTime.

Constants

MINUTE

minute in seconds

HOUR

hour in seconds

DAY

day in seconds

WEEK

week in seconds

MONTH

average month in seconds

YEAR

average year in seconds

Methods

static DateTime
from(string|int|DateTimeInterface|null $time)

Creates a DateTime object from a string, UNIX timestamp, or other DateTimeInterface object.

static DateTime
fromParts(int $year, int $month, int $day, int $hour = 0, int $minute = 0, float $second = 0.0)

Creates DateTime object.

static static|false
createFromFormat(string $format, string $datetime, string|DateTimeZone|null $timezone = null)

Returns a new DateTime object formatted according to the specified format.

__construct(string $datetime = 'now', DateTimeZone|null $timezone = null)

No description

modify(string $modifier)

No description

setDate(int $year, int $month, int $day)

No description

setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0)

No description

static int
relativeToSeconds(string $relativeTime)

Converts a relative time string (e.g. '10 minut') to seconds.

string
jsonSerialize()

Returns JSON representation in ISO 8601 (used by JavaScript).

string
__toString()

Returns the date and time in the format 'Y-m-d H:i:s'.

modifyClone(string $modify = '')

You'd better use: (clone $dt)->modify(...)

Details

at line 43
static DateTime from(string|int|DateTimeInterface|null $time)

Creates a DateTime object from a string, UNIX timestamp, or other DateTimeInterface object.

Parameters

string|int|DateTimeInterface|null $time

Return Value

DateTime

Exceptions

Exception

at line 65
static DateTime fromParts(int $year, int $month, int $day, int $hour = 0, int $minute = 0, float $second = 0.0)

Creates DateTime object.

Parameters

int $year
int $month
int $day
int $hour
int $minute
float $second

Return Value

DateTime

Exceptions

Exception

at line 84
static static|false createFromFormat(string $format, string $datetime, string|DateTimeZone|null $timezone = null)

Returns a new DateTime object formatted according to the specified format.

Parameters

string $format
string $datetime
string|DateTimeZone|null $timezone

Return Value

static|false

at line 99
__construct(string $datetime = 'now', DateTimeZone|null $timezone = null)

No description

Parameters

string $datetime
DateTimeZone|null $timezone

at line 105
DateTime modify(string $modifier)

No description

Parameters

string $modifier

Return Value

DateTime

at line 112
DateTime setDate(int $year, int $month, int $day)

No description

Parameters

int $year
int $month
int $day

Return Value

DateTime

at line 121
DateTime setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0)

No description

Parameters

int $hour
int $minute
int $second
int $microsecond

Return Value

DateTime

at line 138
static int relativeToSeconds(string $relativeTime)

Converts a relative time string (e.g. '10 minut') to seconds.

Parameters

string $relativeTime

Return Value

int

at line 176
string jsonSerialize()

Returns JSON representation in ISO 8601 (used by JavaScript).

Return Value

string

at line 185
string __toString()

Returns the date and time in the format 'Y-m-d H:i:s'.

Return Value

string

at line 194
DateTime modifyClone(string $modify = '')

You'd better use: (clone $dt)->modify(...)

Parameters

string $modify

Return Value

DateTime