Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of date formatting in C #

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is the method of C# date formatting". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought. Let's study and learn "what is the method of C# date formatting"!

C # date format in order to achieve different display effects, sometimes we need to convert the time. The default format is: 2009-06-18 14:33:34. To convert to other formats, use the DateTime.ToString method (String, IFormatProvider), as shown below:

String method for formatting C # dates:

Using System; using System.Globalization; String format= "D"; DateTime date=DataTime,Now; Response.Write (date.ToString (format, DateTimeFormatInfo.InvariantInfo))

Result output

Thursday, June 18, 2009

C # date formatted parameters format format detailed usage: description of format characters and associated attributes

D:ShortDatePattern

D:LongDatePattern

F: full date and time (long date and short time)

F:FullDateTimePattern (long date and long time)

G: general (short date and short time)

G: general (short date and long time)

M 、 M:MonthDayPattern

R 、 R:RFC1123Pattern

S: use local time SortableDateTimePattern (based on ISO 8601)

T:ShortTimePattern

T:LongTimePattern

The format used by u:UniversalSortableDateTimePattern to display universal time

U: full date and time using universal time (long date and long time)

Y 、 Y:YearMonthPattern

Thank you for your reading, the above is the content of "what is the method of C# date formatting". After the study of this article, I believe you have a deeper understanding of what the method of C# date formatting is. The specific use of the situation also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report