C# DateTime to “YYYYMMDDHHMMSS” format

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

    An easy Method, Full control over 'from type' and 'to type', and only need to remember this code for future castings

    DateTime.ParseExact(InputDate, "dd/MM/yyyy", CultureInfo.InvariantCulture).ToString("yyyy/MM/dd"));
    

提交回复
热议问题