C# Time Zone Logic

We currently self-host an application in MST but users in all timezones access this application. The bad part is that it always points to the Server in MST and subsequently appointments made are showing up as times in MST instead of EST, CST, etc.

I was able to go into IIS and find a .cs file that contains the following code. I am not sure if this definitively is the DateTime object it is pointing to, but any assistance is greatly appreciated.

I’m rusty on my C# logic but what I can remember is that DateTime.Now points back to the time zone of the server but can a DateTime.Offset use the timezone of the end user computer?

public DataTable dtEvents = new DataTable();     public DataRow dtRow;     public string sST = "12:00 AM";     public string sET = "11:59 PM";     public string sSD = DateTime.Now.ToShortDateString();     public string sED = DateTime.Now.ToShortDateString();     public string todayDate = DateTime.Now.ToShortDateString();     public string startDate = DateTime.Now.ToShortDateString();     DateTime dtST = DateTime.Now; //row.StartTime;     DateTime dtET = DateTime.Now; //row.EndTime;     //object[] AppointmentData = new object[15];   DateTime dtToday = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 7, 0, 0); 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.