Hey all!
Here's the scenario:
- I've got an array of strings (Dates, but stored in a string[])
- For each date in this array, I need to parse it as a universal DateTime EG "yyyy-MM-ddTHH:mm:ss.fff"
Because it's a string, I can't perform the parse AND make the format conversion, so I tried parsing the date string as a DateTime WITHOUT performing the format conversion... This is fine...
Now that I've got my DateTime in a culturaly biased format, I can convert to the "yyyy-MM-ddTHH:mm:ss.fff"
but when I try to parse a final DateTime value (called newDateTime) it automatically converts it back to my cultural DateTime!
Any suggestions to remedy this?
Many thanks for reading
Rob
NB. Below is my code... dateCollection is a collections of dates in universal DateTime format
foreach (string daystr in e.Days)
{
DateTime parsedDateTime = DateTime.Parse(daystr);
string newDateTime = parsedDateTime.ToString("yyyy-MM-ddTHH:mm:ss.fff");//.ToString("u");
DateTime date = DateTime.Parse(newDateTime, CultureInfo.InvariantCulture);
if (!dateCollection.Contains(date))
{
dateCollection.Add(date);
}
}