<?php
function toUserTz(int|string $utcTime, string $tz = 'America/Chicago', string $format = 'Y-m-d H:i T'): string {
$t = is_int($utcTime) ? $utcTime : strtotime($utcTime . ' UTC');
$dt = new DateTime('@' . $t); // always UTC
$dt->setTimezone(new DateTimeZone($tz));
return $dt->format($format);
}
echo toUserTz(1735689600, 'America/Chicago'); // 2024-12-31 18:00 CST
echo toUserTz(1735689600, 'Asia/Tokyo'); // 2025-01-01 09:00 JST
Create a free account and build your private vault. Share publicly whenever you want.