Is there a way to define the timezone for an application in ASP.NET such that all times read from/compared to current server time are implicitly converted, or do I need to put in conversion statements as each and every DateTime.Now call?
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.
I am not sure about the latest evolutions of ASP, but this article from 2006 provides an interesting answer:
What follows may not be need with .Net 3.5 and its TimeZoneInfo..ConvertTime method, but still, for completeness sake:
1) Get the stored timezone value for the user
2) Create a SimpleTimeZone class to wrap it (using some mapping scheme that maps a DB value to the underlying Windows registry version)
3) Use the SimpleTimeZone.ToLocalTime method to convert the DateTime value to the local time.
1) Get the stored timezone value from the user
2) Create a SimpleTimeZone class to wrap it
3) Use SimpleTimeZone.ToUniversalTime method to convert the DateTime to UTC.