Encodera

Thanks for reading!

Donate to the site — we work hard for you.

How to convert a time to another time zone

Short answer

Create the date in its original zone and call setTimezone():

<?php
 
$utc = new DateTimeImmutable('2026-03-15 12:00', new DateTimeZone('UTC'));
 
echo $utc->setTimezone(new DateTimeZone('Europe/Paris'))->format('Y-m-d H:i'), "\n";
echo $utc->setTimezone(new DateTimeZone('Asia/Tokyo'))->format('Y-m-d H:i');

Output:

2026-03-15 13:00
2026-03-15 21:00

Store time in UTC

Time is stored in the database in UTC and converted to the user's zone only for display. The moment in time does not change — only its notation does:

<?php
 
$utc = new DateTimeImmutable('2026-03-15 12:00', new DateTimeZone('UTC'));
$tokyo = $utc->setTimezone(new DateTimeZone('Asia/Tokyo'));
 
var_dump($utc == $tokyo);
var_dump($utc->getTimestamp() === $tokyo->getTimestamp());

Output:

bool(true)
bool(true)

Functions used in this recipe

Thanks for reading!

Donate to the site — we work hard for you.