Home > Deveploment and Programming > Get list of System Time Zone using c#

Get list of System Time Zone using c#

1. List of system time zone

            ReadOnlyCollection<TimeZoneInfo> tzCollection = TimeZoneInfo.GetSystemTimeZones();
2.  Get time against time zone

 Hashtable ht = new Hashtable();
        private void Form1_Load(object sender, EventArgs e)
        {
            ReadOnlyCollection<TimeZoneInfo> tzCollection = TimeZoneInfo.GetSystemTimeZones();
            foreach (TimeZoneInfo timeZone in tzCollection)
            {
               // comboBox1.Items.Add(timeZone.DisplayName.ToString());
                ht.Add(timeZone.DisplayName, timeZone.Id);
            }
            comboBox1.DataSource = tzCollection;
}
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DateTime dd = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, ht[comboBox1.Text].ToString());
            label1.Text = dd.ToString();

        }

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: