19declare(strict_types=1);
27use InvalidArgumentException;
43 if (!in_array(
$timezone, timezone_identifiers_list(),
true)) {
44 throw new InvalidArgumentException(
"$timezone is not a valid timezone identifier", 1);
46 $this->timezone =
new DateTimeZone(
$timezone);
54 if (!$from instanceof DateTimeImmutable) {
55 throw new InvalidArgumentException(
"$from is not a DateTimeImmutable-object", 1);
58 $ts = $from->format(
'Y-m-d H:i:s');
60 return new DateTimeImmutable($ts, $this->timezone);
Change the timezone (and only the timezone) of php's \DateTimeImmutable WITHOUT changing the date-val...
__construct(string $timezone)
transform($from)
@inheritDoc
trait DeriveInvokeFromTransform
trait DeriveApplyToFromTransform