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

后端 未结 4 491
爱一瞬间的悲伤
爱一瞬间的悲伤 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:12

    Here are all the possible formats ..

    1. MM/dd/yyyy 08/22/2006
    2. ffffdd, dd MMMM yyyy Tuesday, 22 August 2006
    3. ffffdd, dd MMMM yyyy HH:mm Tuesday, 22 August 2006 06:30
    4. ffffdd, dd MMMM yyyy hh:mm tt Tuesday, 22 August 2006 06:30 AM
    5. ffffdd, dd MMMM yyyy H:mm Tuesday, 22 August 2006 6:30
    6. ffffdd, dd MMMM yyyy h:mm tt Tuesday, 22 August 2006 6:30 AM
    7. ffffdd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
    8. MM/dd/yyyy HH:mm 08/22/2006 06:30
    9. MM/dd/yyyy hh:mm tt 08/22/2006 06:30 AM
    10. MM/dd/yyyy H:mm 08/22/2006 6:30
    11. MM/dd/yyyy HH:mm:ss 08/22/2006 06:30:07
    12. MMMM dd August 22
    13. yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK 2006-08-22T06:30:07.7199222-04:00
    14. ffffd, dd MMM yyyy HH':'mm':'ss 'GMT' Tue, 22 Aug 2006 06:30:07 GMT
    15. yyyy'-'MM'-'dd'T'HH':'mm':'ss 2006-08-22T06:30:07
    16. HH:mm 06:30
    17. hh:mm tt 06:30 AM
    18. H:mm 6:30
    19. h:mm tt 6:30 AM
    20. HH:mm:ss 06:30:07
    21. yyyy'-'MM'-'dd HH':'mm':'ss'Z' 2006-08-22 06:30:07Z
    22. ffffdd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
    23. yyyy MMMM 2006 August

提交回复
热议问题