如何将东部时区转换为CENTRAL TIME ZONE

Zec*_*eck 3 php timezone timestamp

我有时间在东部时区,但我想将它调整到中央时区.两个时区都在美国.我以前从来没有这样做过?我不知道如何转换它.请帮我?

Álv*_*lez 11

这是一种可能的方法:

$dt = new DateTime('2011-02-22 16:15:20', new DateTimeZone('America/New_York'));
echo $dt->format('r') . PHP_EOL;

$dt->setTimezone(new DateTimeZone('America/Chicago'));
echo $dt->format('r') . PHP_EOL;
Run Code Online (Sandbox Code Playgroud)

您可以通过以下方式获取可用时区列表:

print_r(DateTimeZone::listIdentifiers());
Run Code Online (Sandbox Code Playgroud)