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 ~