I am using an API that outputs dates in this format 20120314T130000 .
The date value is 13:00 14 March 2012. How can I parse a Date in this format to a .Net DateTime variable in C#?
Also what is this date format known as?
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.
That’s ISO 8601. The ‘-‘ separators are optional in this format.
You can’t parse it with the normal DateTime.Parse method, but you can use ParseExact:
If you have a mix of dates, some with separators and some without, you might need to use a regex to extract the relevant information and then construct the DateTime object.