DateTimeImmutable
class DateTimeImmutable implements DateTimeInterface (View source)
Methods
(PHP 5 >=5.5.0)
Adds an amount of days, months, years, hours, minutes and seconds
(PHP 5 >=5.5.0)
Returns new DateTimeImmutable object formatted according to the specified format
(PHP 5 >=5.6.0)
Returns new DateTimeImmutable object encapsulating the given DateTime object
(PHP 5 >=5.5.0)
Returns the warnings and errors
(PHP 8 >=8.3.0)
Alters the timestamp
(PHP 5 >=5.5.0)
The __set_state handler
(PHP 5 >=5.5.0)
Sets the date
(PHP 5 >=5.5.0)
Sets the ISO date
(PHP 5 >=5.5.0)
Sets the time
(PHP 5 >=5.5.0)
Sets the date and time based on an Unix timestamp
(PHP 5 >=5.5.0)
Subtracts an amount of days, months, years, hours, minutes and seconds
(PHP 5 >=5.5.0)
Returns the difference between two DateTime objects
(PHP 5 >=5.5.0)
Returns date formatted according to given format
(PHP 5 >=5.5.0)
Returns the timezone offset
(PHP 5 >=5.5.0)
Gets the Unix timestamp
(PHP 5 >=5.5.0)
Return time zone relative to given DateTime
(PHP 5 >=5.5.0)
The __wakeup handler
No description
No description
No description
No description
No description
Details
__construct(string $datetime = "now", null|DateTimeZone $timezone = null)
(PHP 8 >=8.3.0)
DateTimeImmutable
add(DateInterval $interval)
(PHP 5 >=5.5.0)
Adds an amount of days, months, years, hours, minutes and seconds
static DateTimeImmutable|false
createFromFormat(string $format, string $datetime, null|DateTimeZone $timezone = null)
(PHP 5 >=5.5.0)
Returns new DateTimeImmutable object formatted according to the specified format
static DateTimeImmutable
createFromMutable(DateTime $object)
(PHP 5 >=5.6.0)
Returns new DateTimeImmutable object encapsulating the given DateTime object
static array|false
getLastErrors()
(PHP 5 >=5.5.0)
Returns the warnings and errors
DateTimeImmutable|false
modify(string $modifier)
(PHP 8 >=8.3.0)
Alters the timestamp
static DateTimeImmutable
__set_state(array $array)
(PHP 5 >=5.5.0)
The __set_state handler
DateTimeImmutable
setDate(int $year, int $month, int $day)
(PHP 5 >=5.5.0)
Sets the date
DateTimeImmutable
setISODate(int $year, int $week, int $dayOfWeek = 1)
(PHP 5 >=5.5.0)
Sets the ISO date
DateTimeImmutable
setTime(int $hour, int $minute, int $second = 0, int $microsecond = 0)
(PHP 5 >=5.5.0)
Sets the time
DateTimeImmutable
setTimestamp(int $timestamp)
(PHP 5 >=5.5.0)
Sets the date and time based on an Unix timestamp
DateTimeImmutable
setTimezone(DateTimeZone $timezone)
(PHP 5 >=5.5.0)
Sets the time zone
DateTimeImmutable
sub(DateInterval $interval)
(PHP 5 >=5.5.0)
Subtracts an amount of days, months, years, hours, minutes and seconds
DateInterval
diff(DateTimeInterface $targetObject, bool $absolute = false)
(PHP 5 >=5.5.0)
Returns the difference between two DateTime objects
string
format(string $format)
(PHP 5 >=5.5.0)
Returns date formatted according to given format
int
getOffset()
(PHP 5 >=5.5.0)
Returns the timezone offset
int
getTimestamp()
(PHP 5 >=5.5.0)
Gets the Unix timestamp
DateTimeZone|false
getTimezone()
(PHP 5 >=5.5.0)
Return time zone relative to given DateTime
void
__wakeup()
(PHP 5 >=5.5.0)
The __wakeup handler
static DateTimeImmutable
createFromInterface(DateTimeInterface $object)
No description
array
__serialize()
No description
void
__unserialize(array $data)
No description
static DateTimeImmutable
createFromTimestamp(int|float $timestamp)
No description
int
getMicrosecond()
No description
setMicrosecond(int $microsecond)
No description