I am trying to parse 11/23/2011 23:59:59 UTC +0800 as a c# datetime object but trying the standard datetime parse method or even the datetime exact parse I get invalid date.
Any ideas?
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 would suggest you parse to a
DateTimeOffsetinstead of aDateTime, as recommended in MSDN when using a time zone offset specifier in the format string:You can then convert that to a
DateTimevalue in UTC if you want, but there’s no such thing as “aDateTimewith an offset of 8 hours” – aDateTimeis either regarded as universal, local or unspecified, with nowhere for a specific offset to be stored.DateTimeis a curious type in various ways, and can cause problems for the unwary developer.