0

How can I best convert a DateTime having only the GMT offset int available to me, adhering to DST and all things such as that? It seems rather convoluted. There must be a simple way. In C# .Net. Sorry, almost forgot to say.

huysentruitw
  • 27,376
  • 9
  • 90
  • 133
James
  • 99
  • 1
  • 2
  • 7

1 Answers1

1

Look at TimeZoneInfo.ConvertTime(). Requires .NET 3.5 or later.

https://msdn.microsoft.com/en-us/library/bb382770(v=vs.110).aspx

S. Rojak
  • 454
  • 2
  • 6
  • This is a web app. The problem is that all I will know is the customer's UTC/GMT offset (-6, -5, etc) and I have customers all over the country. Need to finagle report start and end DateTimes properly having only that in hand. Local would give me the web server's time, right? – James Dec 31 '15 at 04:55
  • You can give the method any convert-from and convert-to time zone. However, you would have to know the customer's time zone. So if the customer is in Arizona, you would want no know not only the time zone offset but whether that customer is or is not observing DST. – S. Rojak Jan 04 '16 at 20:31