Replies: 1 comment 3 replies
-
Hi @scuben sorry for the late answer. The code below should make it possible to set the timezone for a date: (new \CuyZ\Valinor\MapperBuilder())
->registerConstructor(
function (\DateTimeInterface $datetime, \DateTimeZone $timezone): \DateTimeInterface {
return $datetime->setTimezone($timezone);
},
)
->mapper()
->map(\DateTimeInterface::class, [
'datetime' => '2024-03-27T21:12:27+00:00',
'timezone' => 'America/New_York',
]); Would it fit your case? I'll be thinking about adding this to the core. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there!
I try to map a JSON containing a date string to a
DateTimeImmutable
. During this, I want to set a specific timezone. In regular php code this would benew DateTimeImmutable('2023-10-24 08:00:00', new DateTimeZone('Europe/Zurich'))
.How can I achieve that with this library?
Beta Was this translation helpful? Give feedback.
All reactions