Parse C# string to DateTime

后端 未结 3 878
暗喜
暗喜 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:50

    You could use:

    DateTime dt = DateTime.ParseExact(
                      date, 
                      "ddMMyyyyHHmm",
                      CultureInfo.InvariantCulture);
    

提交回复
热议问题