If you have an already instantiated
DateTime object, then you can change its time zone by calling the
DateTime::setTimezone() method, for example, in the following way:
For example, consider the following
DateTime object that's instantiated with a time zone set to
'Europe/London', but is later changed to
'Europe/Berlin' by using the
$dt = new new DateTime('now', new DateTimeZone('Europe/London')); // ... $dt->setTimezone(new DateTimeZone('Europe/Berlin')); // ...
This post was published (and was last revised ) by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.