Generating a List of Timezones with PHP

I often find myself developing applications that need to support users in different timezones, it is important to these users that dates are displayed in their preferred timezone. I thought I would share with you the function I use to create a list of timezones, each with their current UTC offset.

The following function will return a list of timezones ordered by their UTC offset and timezone identifier in ascending order.

Here is the format of the array which this function returns:

You could for example use this to generate an HTML drop down select of timezones using the following code:

I hope this comes in handy!