Culture
-related information when parsing Date
and Time
-s CS-W1092Failing to pass Culture
-related information when parsing Date
and Time
-s prompts the runtime to use the host system's information.
If your application runs on systems that are spread across different regions with different locales, this can cause problems with the formatting.
One such example is DD/MM and MM/DD. To avoid such pitfalls, always pass in the Culture
-related information.
var parsed = DateTime.Parse(s);
var parsed = DateTime.Parse(s, new CultureInfo("en-US"));