Get string timezone from numeric timezone value PHP

Is there a way to find Timezone string from timestamp Integer value?

My Integer value : +5.5

What I want to get

Read More
Asia/Colombo

I’m working on WordPress, Is there an easy way to get that on WP?

Related posts

Leave a Reply

2 comments

  1. I would use DateTimeZone::listIdentifiers()

    $time_zones =  DateTimeZone::listIdentifiers();
    
    foreach ($time_zones as $time_zone) {
        $date = new DateTime('now', new DateTimeZone($time_zone));
        $offset_in_hours = $date->getOffset() / 60 / 60;
        echo "{$time_zone}: ($offset_in_hours)";
    }
    

    This will output something like:

    Asia/Choibalsan: (9)
    Asia/Colombo: (5.5)
    Asia/Damascus: (3)
    Asia/Dhaka: (6)
    Asia/Dili: (9)
    Asia/Dubai: (4)
    

    Then you can wrap this code inside a plugin/shortcode and use the output to reverse search your time zone.