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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners