International PHP Conference Berlin 2023

A classe DateTimeImmutable

(PHP 5 >= 5.5.0, PHP 7, PHP 8)

Introdução

Essa classe têm o mesmo comportamento que DateTime, com exceção de nunca ser modificada, mas retornará um novo objeto.

Sinopse da classe

class DateTimeImmutable implements DateTimeInterface {
/* Métodos */
public __construct(string $time = "now", DateTimeZone $timezone = null)
public static createFromFormat(string $format, string $time, DateTimeZone $timezone = ?): DateTimeImmutable
public static createFromMutable(DateTime $datetime): DateTimeImmutable
public static getLastErrors(): array
public modify(string $modify): DateTimeImmutable
public static __set_state(array $array): DateTimeImmutable
public setDate(int $year, int $month, int $day): DateTimeImmutable
public setISODate(int $year, int $week, int $day = 1): DateTimeImmutable
public setTime(int $hour, int $minute, int $second = 0): DateTimeImmutable
public setTimestamp(int $unixtimestamp): DateTimeImmutable
public diff(DateTimeInterface $datetime2, bool $absolute = false): DateInterval
public format(string $format): string
public getOffset(): int
public getTimestamp(): int
public __wakeup()
}

Índice

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top