C# : How to convert string to DateTime, where the string can have any of the standard datetime format

后端 未结 4 488
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-04 17:47

I had posted a question on DateTime to String conversion, I got many satisfying answers for that .. so I thank StackOverflow very much ..
Here is one more problem of String

4条回答
  •  一生所求
    2021-02-04 18:30

    DateTime dt1 = DateTime.ParseExact("2007/01/01 04:23:12", "yyyy/MM/dd hh:mm:ss", System.Globalization.CultureInfo.CurrentCulture);

    DateTime dt = Convert.ToDateTime("2007/01/01 04:23:12", System.Globalization.CultureInfo.CurrentCulture);

    System.Globalization.CultureInfo.CurrentCulture format param

提交回复
热议问题