String was not recognized as a valid DateTime?

后端 未结 4 510
青春惊慌失措
青春惊慌失措 2021-01-20 02:31

I try to convert string to datetime but each time I get :

String was not recognized as a valid DateTime.

Code is:

4条回答
  •  无人及你
    2021-01-20 02:45

    I agree with the other answers that it looks like your doing a lot to solve what should be a simple problem. I'd use the British date format from the culture info.

    var convertedDay = DateTime.Parse("12/04/2010", new CultureInfo("en-GB").DateTimeFormat);
    

提交回复
热议问题