PHP Velho Oeste 2024

DateTimeImmutable::__construct

date_create_immutable

(PHP 5 >= 5.5.0, PHP 7)

DateTimeImmutable::__construct -- date_create_immutableReturns new DateTimeImmutable object

설명

객체 기반 형식

public DateTimeImmutable::__construct ([ string $time = "now" [, DateTimeZone $timezone = NULL ]] )

절차식 형식

DateTimeImmutable date_create_immutable ([ string $time = "now" [, DateTimeZone $timezone = NULL ]] )

Like DateTime::__construct() but works with DateTimeImmutable.

add a note add a note

User Contributed Notes 1 note

up
0
Dmitrii
1 year 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