I have these datetimes which appear to me to be in an odd standard..
2004/05/17 21:27:16.162 GMT-7
2006/08/01 01:00:00 GMT-7
2010/11/05 13:00:38.844 US/Pacific
Any ideas on how I can parse them in C#? Or has anyone seen them before?
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.
2010/11/05 13:00:38.844 US/Pacificis something which you cannot parse in pure .Net, at least not in localized form. For others, it really depends on whether you know format. If you do, you can use DateTime’sParseExact()method:Please keep in mind, that I used InvariantCulture because I knew it is exactly the same as
en-US. For correct results you would need to use valid CultureInfo.Last, but not least: why you want to parse these invalid formats anyway? I would suggest to fix the source of the problem and use local default formats (depending on the culture as well as local time for current user’s location) rather than creating your own. Special formats make understanding time harder as they are unnatural for end users.