C# DateTime to “YYYYMMDDHHMMSS” format

后端 未结 18 1572
故里飘歌
故里飘歌 2020-11-22 01:53

I want to convert a C# DateTime to \"YYYYMMDDHHMMSS\" format. But I don\'t find a built in method to get this format? Any comments?

18条回答
  •  孤独总比滥情好
    2020-11-22 02:45

    Get the date as a DateTime object instead of a String. Then you can format it as you want.

    • MM/dd/yyyy 08/22/2006
    • ffffdd, dd MMMM yyyy Tuesday, 22 August 2006
    • ffffdd, dd MMMM yyyy HH:mm Tuesday, 22 August 2006 06:30
    • ffffdd, dd MMMM yyyy hh:mm tt Tuesday, 22 August 2006 06:30 AM
    • ffffdd, dd MMMM yyyy H:mm Tuesday, 22 August 2006 6:30
    • ffffdd, dd MMMM yyyy h:mm tt Tuesday, 22 August 2006 6:30 AM
    • ffffdd, dd MMMM yyyy HH:mm:ss Tuesday, 22 August 2006 06:30:07
    • MM/dd/yyyy HH:mm 08/22/2006 06:30
    • MM/dd/yyyy hh:mm tt 08/22/2006 06:30 AM
    • MM/dd/yyyy H:mm 08/22/2006 6:30
    • MM/dd/yyyy h:mm tt 08/22/2006 6:30 AM
    • MM/dd/yyyy HH:mm:ss 08/22/2006 06:30:07

    Click here for more patterns

提交回复
热议问题