How to create a list of time zones programmatically

It's very easy to create a list of timezones! And that is very useful too!!

Imagine that you are developing an application which requires the user to choose in which time zone he is located. Now picture yourself adding 40 time zones into a dropdownlist manually.

Unless you need to have the list of time zones in the database you can just use the following code snippet:

public static IEnumerable<SelectListItem> TimeZoneCollection
{
	get
	{
		return new SelectList(TimeZoneInfo.GetSystemTimeZones()
			.Select(q => new SelectListItem
						{
							Text = q.DisplayName,
							Value = (q.DisplayName.Substring(0, 5) != "(UTC)") ? q.DisplayName.Substring(4, 3) : "0"
						}
 
				    ), "Value""Text");
	}
}

Now just bind it into a dropdownlist and voilà.

P.S.: Let me know in case you have improved the code. :)