<?php $a = new \DateTimeImmutable('2021-01-01', new \DateTimeZone('Europe/Berlin')); $b = (clone $a); // $c = (clone $a)->setTimeZone(new \DateTimeZone('Europe/Paris')); // Same GMT offset but different timezone $d = (clone $a)->setTimeZone(new \DateTimeZone('Australia/Sydney')); // Different timezone $e = (clone $a)->modify('+1 second'); // Insufficient check assert($a == $b); assert($a == $c); assert($a == $d); assert($a != $e); // Check that accounts for timezone name (not just offset) assert($a->format('ce') === $b->format('ce')); assert($a->format('ce') !== $c->format('ce')); assert($a->format('ce') !== $d->format('ce')); assert($a->format('ce') !== $e->format('ce')); echo 'Done.';
You have javascript disabled. You will not be able to edit any code.