I have two different columns to store date And time. One is saving date and other is Time. Before i did it with local time it was working fine. Now i want to set this time for Arizona So for that i convert my date time to UTC time and the Used TimeZoneIfo‘s Method ConvertTime to get Arizona’s Time.
Now My Problem is I can get date using this but while i am saving Time its coming in 12 hours format i want to convert it to 24 hours.
My code is
DateTime UniversalScheduleDate = Convert.ToDateTime(txtDate.Text).ToUniversalTime();
TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(Session["TimeZone"].ToString());
objSchdl.SDate = TimeZoneInfo.ConvertTime(UniversalScheduleDate, timeZoneInfo);
DateTime UniversalStartTime = Convert.ToDateTime(txtStartTime.Text).ToUniversalTime();
objSchdl.Stime = TimeZoneInfo.ConvertTime(UniversalStartTime, timeZoneInfo).ToString();
Please help me..
Try convert using the DateTimeParse along with DateTimeKind.Utc
Example: