C# to Convert String to DateTime

前端 未结 6 1936
北海茫月
北海茫月 2020-12-21 11:59

How to convert the below string to DateTime in C#?

Mon Apr 22 07:56:21 +0000 2013

When i tried the code with

         


        
6条回答
  •  青春惊慌失措
    2020-12-21 12:53

    You have basically two options for this. DateTime.Parse() and DateTime.ParseExact(). like

    DateTime parseexactdt = DateTime.ParseExact("Mon Apr 22 07:56:21 +0000 2013",
                                       "ffffd MMM d HH:mm:ss +0000 yyyy",
                                       CultureInfo.InvariantCulture);
    

提交回复
热议问题