C# DateTime to “YYYYMMDDHHMMSS” format

后端 未结 18 1593
故里飘歌
故里飘歌 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:42

    You've practically written the format yourself.

    yourdate.ToString("yyyyMMddHHmmss")

    • MM = two digit month
    • mm = two digit minutes
    • HH = two digit hour, 24 hour clock
    • hh = two digit hour, 12 hour clock

    Everything else should be self-explanatory.

提交回复
热议问题