How do I parse this date format:
/Date(1402537043438+1000)/
to a C# DateTime?
I'm limited to .Net 3.5 and can't use a nuget package like Newtonsoft.
How do I parse this date format:
/Date(1402537043438+1000)/
to a C# DateTime?
I'm limited to .Net 3.5 and can't use a nuget package like Newtonsoft.
JavaScriptSerializer (an external assembly, of sorts, but not a NuGet requirement) can parse those dates, but they need to have a \ at the start and end of the string, e.g.:
var date = "/Date(1402537043438+1000)/";
var parsedDate = new JavaScriptSerializer().Deserialize<DateTime>("\"" + date.Replace("/", "\\/") + "\"");
date variable. What I'm doing is modifying that variable to make it a valid JSON format for the serializerJavaScriptSerializer will serialize to) because JSON doesn't actually specify a way to handle Dates. It seems wacky, because it technically is just a wacky workaround to a limitation of the JSON format :)