DateTimeImmutable::__construct

date_create_immutable

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

DateTimeImmutable::__construct -- date_create_immutableDevuelve un nuevo objeto DateTimeImmutable

Descripción

Estilo orientado a objetos

public DateTimeImmutable::__construct(string $time = "now", DateTimeZone $timezone = null)

Estilo por procedimientos

Igual que DateTime::__construct() excepto que trabaja con DateTimeImmutable.

add a note

User Contributed Notes 1 note

up
1
Dmitrii
11 months ago
"If $timezone is omitted or null, the current timezone will be used." - note, that timezone IS NOT equal offset, if its important for your application.

If default timezone = Europe/Moscow, then:
echo (new \DateTimeImmutable('2014-10'))->format(DATE_ATOM); // gives "2014-10-01T00:00:00+04:00"
echo (new \DateTimeImmutable('2014-11'))->format(DATE_ATOM); // gives "2014-11-01T00:00:00+03:00"
because of law changes (abolition of "summer time").
To Top