In this post we will discuss how to get all time zones in Asp.Net using C#.Net.
Also you can check out some posts on:
- Convert ArrayList to String using C#.Net
- Object Oriented Programming (OOP) concepts in .Net
- List all Stored Procedure Created and Modified in Last N Days in SQL Server 2008
Here we will bind all the system time zones to a dropdownlist.
Below is the full code:
The above code will bind all the timezones like below:
If you want to get the system timezone, then you can do like below:
Also you can check out some posts on:
- Convert ArrayList to String using C#.Net
- Object Oriented Programming (OOP) concepts in .Net
- List all Stored Procedure Created and Modified in Last N Days in SQL Server 2008
Here we will bind all the system time zones to a dropdownlist.
Below is the full code:
Select TimeZone: <asp:DropDownList ID="ddlTimeZone" runat="server">
</asp:DropDownList>
void
BindAllTimeZones()
{
foreach (TimeZoneInfo
timeZone in TimeZoneInfo.GetSystemTimeZones())
{
ddlTimeZone.Items.Add(timeZone.DisplayName);
}
}
The above code will bind all the timezones like below:
If you want to get the system timezone, then you can do like below:
TimeZoneInfo tlocal = TimeZoneInfo.Local;
ddlTimeZones.SelectedItem.Text
= tlocal.ToString();