Date Formatting C#

前端 未结 7 1344
生来不讨喜
生来不讨喜 2021-01-27 08:32

I am having an issue converting this date format into another format. I was hoping that somebody on here would be able to help me out.

Here is my code:

s         


        
相关标签:
7条回答
  • 2021-01-27 09:35

    There are two issues:

    1) The day selected was a Friday not a Monday

    2) The 'zzz' wants a plus or minus 0:00

    So, to get it to work would be:

    string fromFormat = "ffffd, dd MM yyyy HH:mm:ss zzz";
    string toFormat = "yyyy-MM-dd";
    
    DateTime newDate = DateTime.ParseExact("Fri, 22 03 2013 00:00:00 +0:00", fromFormat, null);
    
    Console.WriteLine(newDate.ToString(toFormat));
    
    0 讨论(0)
提交回复
热议问题