phptimezonetimestamp

How to convert Eastern Time Zone to CENTRAL TIME ZONE


I have a time that is being in Eastern Time Zone, but I want to adjust it to CENTRAL TIME ZONE. Both time zones are in USA. I never do it before? I don't know how to convert it. Please help me?


Solution

  • This is one possible method:

    $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;
    

    You can get a list of available time zones with:

    print_r(DateTimeZone::listIdentifiers());