Formatted string of DateTime. Now. ToString in. NET, datetime. tostring

Source: Internet
Author: User
Tags iso 8601

Formatted string of DateTime. Now. ToString in. NET, datetime. tostring

In. NET, DateTime. Now. ToString is displayed in milliseconds:
DateTime. Now. ToString ("yyyy-MM-dd HH: mm: ss. fff ")
Other formatting strings of DateTime. Now. ToString:
Format a string Meaning Example
D Long date Thursday, 10 then l 2008
D Short date 04/10/2008
F Full date long Thursday, 10 minutes l 2008 06:30:00
F Full date short Thursday, 10 then l 2008
G General long 04/10/2008 06:30:00
G General short
M Month Limit L 10
O ISO 8601 2008-04-10T06: 30: 00.0000000
R RFC 1123 Thu, 10 Apr 2008 06:30:00 GMT
S Sortable 2008-04-10T06: 30: 00
T Long time 06:30:00
T Short time
U Universal full Wednesday, 09 Jun l 2008 22:30:00
U Universal sortable 2008-04-10 06: 30: 00Z
Y Year month 2008 L
Yy-MM-dd Custom 08-04-10
Yyyy MMMM dd Custom 2008 10000l 08
Yy-MMMM-dd ddd Custom 08-Apr-8 Tue
Yyyy-M-d dddd Custom 2008-4-8 Tuesday
Hh: mm: ss t z Custom 04:03:05 P-7
H: mm: ss tt zz Custom 4:03:05 PM-07
HH: mm: ss tt zz Custom 16:03:05 PM-07
HH: m: s tt zzz Custom PM-PM
SourceReSharper.
Of course, you can also use the properties (such as: DateTime. Now. Year) and methods (such as: DateTime. Now. to1_datestring () provided by the DateTime class ()).
The above content is relatively simple, but it is quite useful to meet certain requirements ~
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.