How to check is timezone identifier valid from code?

后端 未结 8 1853
无人及你
无人及你 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:18

    If you're on Linux most if not all information on timezones there stored at /usr/share/zoneinfo/. You can walk over them using is_file() and related functions.

    You can also parse the former files with zdump for codes or fetch sources for these files and grep/cut out needed info. Again, you are not obliged to use built-in functions to accomplish the task. There isn't a rationale why would someone force you to use only the built-in date functions.

提交回复
热议问题