C ++ date formatting in order to achieve different display effects, sometimes we need to convert the time. The default format is: 14:33:34. to convert it to another format, DateTime is used. the ToString method (String, IFormatProvider) is as follows:
- using System; using System.Globalization; String format="D";
- DateTime date=DataTime,Now;
- Response.Write(date.ToString( format, DateTimeFormatInfo.InvariantInfo));
C ++ detailed format usage of the format parameter for date formatting: Description of format characters and associated attributes:
D: ShortDatePattern
D: LongDatePattern
F: complete date and long and short time)
F: FullDateTimePattern long date and long time)
G: regular short date and short time)
G: regular short date and long time)
M, M: MonthDayPattern
R, R: RFC1123Pattern
S: Use the local time of SortableDateTimePattern based on ISO 8601)
T: ShortTimePattern
T: LongTimePattern
U: UniversalSortableDateTimePattern used to display the format of common time
U: use the full date and long time of the general time)
Y, Y: YearMonthPattern
The brief introduction of the C ++ DateTime. ToString Method for date formatting will be introduced here. I hope the DateTime. ToString method that helps you understand and learn C # date formatting will be helpful.
- How to Write C ++ project development and project plan correctly
- Summary Notes on learning and exploring C ++ library functions
- In-depth demonstration of high security of C ++
- Describes in detail how to accurately Write C ++ languages.
- In-depth demonstration of high security of C ++