Source: www.amitmerchant.com

Fetch all the available time zones in PHP
When you’re building a user-facing application, one of the most common scenarios is to let the user decide their respective https://en.wikipedia.org/wiki/Time_zone. Now, one way of doing this is by creating a hard-coded list of time zones and showing them as a list. And if you’re using PHP, you can fetch all the time zones with a single line of code. PHP comes with a handy class called https://www.php.net/manual/en/class.datetimezone.php (available from PHP 5 and older) that can be used for various time zone related needs.

var_dump( DateTimeZone::listIdentifiers( DateTimeZone::ALL )); /* array(425) { => string(14)"Africa/Abidjan" => string(12)"Africa/Accra" => string(18)"Africa/Addis_Ababa" => string(14)"Africa/Algiers" => string(13)"Africa/Asmara" ... } */
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners