DateTime ParseExact string was not recognize as a DateTime C#

后端 未结 2 348
谎友^
谎友^ 2021-01-29 11:54

I\'m trying to parse string as DateTime but I\'m getting an error. here my code

return DateTime.ParseExact(\"01/01/0001 12:00:00 AM\", \"dd/MM/yyyy HH:mm:ss tt\"         


        
2条回答
  •  执念已碎
    2021-01-29 12:07

    You are trying to parse the DateTime exactly, therefore the format has to be exact

    DateTime.ParseExact("01/01/0001 12:00:00 AM", "dd/MM/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
    

提交回复
热议问题