How to check is timezone identifier valid from code?

后端 未结 8 1856
无人及你
无人及你 2020-12-05 04:53

I\'ll try to explain what\'s the problem here.

According to list of supported timezones from PHP manual, I can see all valid TZ identifiers in PHP.

My first

8条回答
  •  醉话见心
    2020-12-05 05:10

    I would research what changes the perfect array and use a basic caching mechanism (like store the array in a file, that you include and update when needed). You're currently optimizing building an array that is static for 99.9999% of all the requests.

    Edit: Ok, static/dynamic.

    if( !function_exists(timezone_version_get) )
    {
        function timezone_version_get() { return '2009.6'; }
    }
    include 'tz_list_' . PHP_VERSION . '_' . timezone_version_get() . '.php';
    

    Now each time the php version is updated, the file should be regenerated automatically by your code.

提交回复
热议问题