Say, if I have a database column that holds date/time in UTC time zone, I can read them into DateTime object in my ASP.NET web app written with C#. How do I convert them to a user provided time zone?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This assumes that
timehas aKind = DateTimeKind.UtcYou could use
ConvertTimeFromUtc:Or
TimeZoneInfo.ConvertTime:You will probably want to check out the MSDN article on
TimeZoneInfo.ConvertTimefor the ins and outs of the method.It’s probably worth reading all about converting between time zones on MSDN as well. It’s more complex than you might think.