The string was not recognized as a valid DateTime. There is an unknown word starting at index 0

前端 未结 5 986
予麋鹿
予麋鹿 2021-01-19 10:53

I have the following C# that is giving me the error above when trying to parse string to datetime.

DateTime backupdate = System.Convert.ToDateTime(imageflowl         


        
5条回答
  •  遥遥无期
    2021-01-19 11:23

    Your code looks correct; the issue is presumably with your string format, whose last : should actually be a . (indicating the start of the fractional seconds).

    Incorrect: 2012-04-15 15:23:34:123
    Correct:   2012-04-15 15:23:34.123
    

    Convert.ToDateTime("2012-04-15 15:23:34.123") works fine.

提交回复
热议问题