-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
Description
Description
The following code:
<?php
echo date_default_timezone_get();
echo PHP_EOL;
$dt = new \DateTimeImmutable();
echo $dt->getTimezone()->getName();
echo PHP_EOL;
$dt1 = new \DateTimeImmutable()->setTimestamp(1742892008);
echo $dt1->getTimezone()->getName();
echo PHP_EOL;
$dt2 = \DateTimeImmutable::createFromTimestamp(1742892008);
echo $dt2->getTimezone()->getName();
echo PHP_EOL;
$dt3 = \DateTimeImmutable::createFromFormat('U', '1742892008');
echo $dt3->getTimezone()->getName();
echo PHP_EOL;Resulted in this output:
UTCUTCUTC
+00:00
+00:00
But I expected this output instead:
UTCUTCUTC
UTC
UTC
PHP Version
8.4.5
Operating System
No response
CreateFromFormat with non-timestamp value seems to working properly:
\DateTimeImmutable::createFromFormat('H:i:s d.m.Y', '09:30:00 25.03.2025') will create object with valid timezone.
Reactions are currently unavailable