Convert DateTime into Specific TimeZone wise with DayLightSavingTime Changes

DateTime date1 = Convert.ToDateTime(“15-03-2010 3:30:00 AM”); //start day of daylighttime
//DateTime date1 = Convert.ToDateTime(“07-11-2010 3:30:00 AM”);
//DateTime date1 = Convert.ToDateTime(“08-11-2010 3:30:00 AM”); // end day of daylighttime

//set local timezone
TimeZoneInfo sourceTimeZone = TimeZoneInfo.Local;

//get system timezones list
System.Collections.ObjectModel.ReadOnlyCollection timeZone = TimeZoneInfo.GetSystemTimeZones();

List tz = timeZone.ToList();

//get event time zone standard name
epp2ClientPL.EventConfigurationProperties result = (epp2ClientPL.EventConfigurationProperties)HttpContext.Current.Session[“EventConfiguration”];
string strZone = tz.AsEnumerable().Where(u => u.DisplayName.Contains(result.EventTitle.Substring(12))).SingleOrDefault().StandardName.ToString();

//set event time zone
TimeZoneInfo destinationTimeZone = TimeZoneInfo.FindSystemTimeZoneById(strZone.ToString());

//convert datetime to event time zone wise
TimeZoneInfo.ConvertTime(date1, destinationTimeZone).ToString(“dd-MM-yyyy hh:mm tt”);

return date1;

Share