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?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
In
.Net Standard 2
you can formatDateTime
like belows:using C# 6.0
I am surprised no one has a link for this . any format can be created using the guidelines here:
Custom Date and Time Format Strings
For your specific example (As others have indicated) use something like
Where my_format can be any string combination of y,M,H,m,s,f,F and more! Check out the link.
An easy Method, Full control over 'from type' and 'to type', and only need to remember this code for future castings
Get the date as a
DateTime
object instead of a String. Then you can format it as you want.Click here for more patterns