Parse C# string to DateTime

后端 未结 3 874
暗喜
暗喜 2020-11-29 10:13

I have a string like this: 250920111414

I want to create a DateTime object from that string. As of now, I use substring and do it like this:

string d         


        
3条回答
  •  一生所求
    2020-11-29 10:43

    string iDate = "05/05/2005";
    DateTime oDate = Convert.ToDateTime(iDate);
    DateTime oDate = DateTime.ParseExact(iString, "yyyy-MM-dd HH:mm tt",null);
    
    
    

    DateTime Formats

提交回复
热议问题