How to convert string with unusual format into datetime

前端 未结 9 939
半阙折子戏
半阙折子戏 2021-01-19 17:15

I\'m using .NET 3.5 and I have a date that comes in as string in the following format:

Tue Jan 20 20:47:43 GMT 2009

First questi

9条回答
  •  独厮守ぢ
    2021-01-19 17:50

    CultureInfo enUS = new CultureInfo( "en-US" ); 
    
    DateTime dt = DateTime.ParseExact( "Tue Jan 20 19:47:43 GMT 2009", "ffffd MMM dd HH:mm:ss 'GMT' yyyy", enUS, DateTimeStyles.None );
    
    Console.WriteLine( dt.ToString() );
    

提交回复
热议问题