Documentation

DateTime extends DateTime
in package
implements JsonSerializable uses SmartObject

DateTime.

Table of Contents

Interfaces

JsonSerializable

Constants

DAY  = 24 * self::HOUR
day in seconds
HOUR  = 60 * self::MINUTE
hour in seconds
MINUTE  = 60
minute in seconds
MONTH  = 2629800
average month in seconds
WEEK  = 7 * self::DAY
week in seconds
YEAR  = 31557600
average year in seconds

Methods

__call()  : mixed
__callStatic()  : mixed
__get()  : mixed
__isset()  : bool
__set()  : void
__toString()  : string
Returns the date and time in the format 'Y-m-d H:i:s'.
__unset()  : void
createFromFormat()  : static|false
Returns new DateTime object formatted according to the specified format.
from()  : static
Creates a DateTime object from a string, UNIX timestamp, or other DateTimeInterface object.
fromParts()  : static
Creates DateTime object.
jsonSerialize()  : string
Returns JSON representation in ISO 8601 (used by JavaScript).
modifyClone()  : static
You'd better use: (clone $dt)->modify(...)

Constants

DAY

day in seconds

public mixed DAY = 24 * self::HOUR

HOUR

hour in seconds

public mixed HOUR = 60 * self::MINUTE

MINUTE

minute in seconds

public mixed MINUTE = 60

MONTH

average month in seconds

public mixed MONTH = 2629800

WEEK

week in seconds

public mixed WEEK = 7 * self::DAY

YEAR

average year in seconds

public mixed YEAR = 31557600

Methods

__call()

public __call(string $name, array<string|int, mixed> $args) : mixed
Parameters
$name : string
$args : array<string|int, mixed>
Tags
throws
MemberAccessException

__callStatic()

public static __callStatic(string $name, array<string|int, mixed> $args) : mixed
Parameters
$name : string
$args : array<string|int, mixed>
Tags
throws
MemberAccessException

__isset()

public __isset(string $name) : bool
Parameters
$name : string
Return values
bool

__set()

public __set(string $name, mixed $value) : void
Parameters
$name : string
$value : mixed
Tags
throws
MemberAccessException

if the property is not defined or is read-only

__toString()

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

public __toString() : string
Return values
string

createFromFormat()

Returns new DateTime object formatted according to the specified format.

public static createFromFormat(string $format, string $time[, string|DateTimeZone|null $timezone = null ]) : static|false
Parameters
$format : string
$time : string
$timezone : string|DateTimeZone|null = null
Return values
static|false

from()

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

public static from(string|int|DateTimeInterface|null $time) : static
Parameters
$time : string|int|DateTimeInterface|null
Tags
throws
Exception

if the date and time are not valid.

Return values
static

fromParts()

Creates DateTime object.

public static fromParts(int $year, int $month, int $day[, int $hour = 0 ][, int $minute = 0 ][, float $second = 0.0 ]) : static
Parameters
$year : int
$month : int
$day : int
$hour : int = 0
$minute : int = 0
$second : float = 0.0
Tags
throws
InvalidArgumentException

if the date and time are not valid.

Return values
static

jsonSerialize()

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

public jsonSerialize() : string
Return values
string

modifyClone()

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

public modifyClone([string $modify = '' ]) : static
Parameters
$modify : string = ''
Return values
static

        
On this page

Search results