How to Get TimeZoneInfo list in C#


using System.Web.Security;
using System.Collections.ObjectModel;
using System.Web;


ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
                List<UTCList> lstUTCList = new List<UTCList>();
                foreach (TimeZoneInfo timeZone in timeZones)
                {
                    lstUTCList.Add(new UTCList() { Name = timeZone.DisplayName, ID = timeZone.Id });
                }

                SelectList objSelectList = new SelectList(lstUTCList, "ID", "Name", "India Standard Time");
 Session["List of Data"] = objSelectList;

public class UTCList
        {
            public string Name { get; set; }
            public string ID { get; set; }
        }

Comments

Popular posts from this blog

Executing PowerShell scripts from C#

HOW TO Use the NumericUpDown Control

Exposing Agile Software Development Myths