打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
DateTime.ToString() Patterns

DateTime.ToString() Patterns

All the patterns:

0MM/dd/yyyy08/22/2006
1dddd, dd MMMM yyyyTuesday, 22 August 2006
2dddd, dd MMMM yyyyHH:mm Tuesday, 22 August 2006 06:30
3dddd, dd MMMM yyyyhh:mm tt Tuesday, 22 August 2006 06:30 AM
4dddd, dd MMMM yyyyH:mm Tuesday, 22 August 2006 6:30
5dddd, dd MMMM yyyyh:mm tt Tuesday, 22 August 2006 6:30 AM
6dddd, dd MMMM yyyy HH:mm:ssTuesday, 22 August 2006 06:30:07
7MM/dd/yyyy HH:mm08/22/2006 06:30
8MM/dd/yyyy hh:mm tt08/22/2006 06:30 AM
9MM/dd/yyyy H:mm08/22/2006 6:30
10MM/dd/yyyy h:mm tt08/22/2006 6:30 AM
 
11MM/dd/yyyy HH:mm:ss08/22/2006 06:30:07
12MMMM ddAugust 22
13MMMM ddAugust 22
14yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK2006-08-22T06:30:07.7199222-04:00
15yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK2006-08-22T06:30:07.7199222-04:00
16ddd, dd MMM yyyy HH':'mm':'ss 'GMT'Tue, 22 Aug 2006 06:30:07 GMT
17ddd, dd MMM yyyy HH':'mm':'ss 'GMT'Tue, 22 Aug 2006 06:30:07 GMT
18yyyy'-'MM'-'dd'T'HH':'mm':'ss2006-08-22T06:30:07
19HH:mm06:30
20hh:mm tt06:30 AM
21H:mm6:30
22h:mm tt6:30 AM
23HH:mm:ss06:30:07
24yyyy'-'MM'-'dd HH':'mm':'ss'Z'2006-08-22 06:30:07Z
25dddd, dd MMMM yyyy HH:mm:ssTuesday, 22 August 2006 06:30:07
26yyyy MMMM2006 August
27yyyy MMMM2006 August

The patterns for DateTime.ToString ( 'd' ) :

0MM/dd/yyyy08/22/2006

The patterns for DateTime.ToString ( 'D' ) :

0dddd, dd MMMM yyyyTuesday, 22 August 2006

The patterns for DateTime.ToString ( 'f' ) :

0dddd, dd MMMM yyyy HH:mmTuesday, 22 August 2006 06:30
1dddd, dd MMMM yyyy hh:mmtt Tuesday, 22 August 2006 06:30 AM
2dddd, dd MMMM yyyy H:mmTuesday, 22 August 2006 6:30
3dddd, dd MMMM yyyy h:mmtt Tuesday, 22 August 2006 6:30 AM

The patterns for DateTime.ToString ( 'F' ) :

0dddd, dd MMMM yyyy HH:mm:ssTuesday, 22 August 2006 06:30:07

The patterns for DateTime.ToString ( 'g' ) :

0MM/dd/yyyy HH:mm08/22/2006 06:30
1MM/dd/yyyy hh:mmtt 08/22/2006 06:30 AM
2MM/dd/yyyy H:mm08/22/2006 6:30
3MM/dd/yyyy h:mm tt08/22/2006 6:30 AM

The patterns for DateTime.ToString ( 'G' ) :

0MM/dd/yyyy HH:mm:ss08/22/2006 06:30:07

The patterns for DateTime.ToString ( 'm' ) :

0MMMM ddAugust 22

The patterns for DateTime.ToString ( 'r' ) :

0ddd, dd MMM yyyy HH':'mm':'ss 'GMT'Tue, 22 Aug 2006 06:30:07 GMT

The patterns for DateTime.ToString ( 's' ) :

0yyyy'-'MM'-'dd'T'HH':'mm':'ss2006-08-22T06:30:07

The patterns for DateTime.ToString ( 'u' ) :

0yyyy'-'MM'-'dd HH':'mm':'ss'Z'2006-08-22 06:30:07Z

The patterns for DateTime.ToString ( 'U' ) :

0dddd, dd MMMM yyyy HH:mm:ssTuesday, 22 August 2006 06:30:07

The patterns for DateTime.ToString ( 'y' ) :

0yyyy MMMM 2006 August

Building a custom DateTime.ToString Patterns

The following details the meaning of each pattern character. Not the K and z character.

dRepresents the day of the month as a number from 1 through 31. A single-digit day is formatted without a leading zero
ddRepresents the day of the month as a number from 01 through 31. A single-digit day is formatted with a leading zero
dddRepresents the abbreviated name of the day of the week (Mon, Tues, Wed etc)
ddddRepresents the full name of the day of the week (Monday, Tuesday etc)
h12-hour clock hour (e.g. 7)
hh12-hour clock, with a leading 0 (e.g. 07)
H24-hour clock hour (e.g. 19)
HH24-hour clock hour, with a leading 0 (e.g. 19)
mMinutes
mmMinutes with a leading zero
MMonth number
MMMonth number with leading zero
MMMAbbreviated Month Name (e.g. Dec)
MMMMFull month name (e.g. December)
sSeconds
ssSeconds with leading zero
tAbbreviated AM / PM (e.g. A or P)
ttAM / PM (e.g. AM or PM
yYear, no leading zero (e.g. 2001 would be 1)
yyYear, leadin zero (e.g. 2001 would be 01)
yyyYear, (e.g. 2001 would be 2001)
yyyyYear, (e.g. 2001 would be 2001)
KRepresents the time zone information of a date and time value (e.g. +05:00)
zWith DateTime values, represents the signed offset of the local operating system's time zone from Coordinated Universal Time (UTC), measured in hours. (e.g. +6)
zzAs z but with leadin zero (e.g. +06)
zzzWith DateTime values, represents the signed offset of the local operating system's time zone from UTC, measured in hours and minutes. (e.g. +06:00)
fRepresents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value.
ffRepresents the two most significant digits of the seconds fraction; that is, it represents the hundredths of a second in a date and time value.
fffRepresents the three most significant digits of the seconds fraction; that is, it represents the milliseconds in a date and time value.
ffffRepresents the four most significant digits of the seconds fraction; that is, it represents the ten thousandths of a second in a date and time value. While it is possible to display the ten thousandths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.
fffffRepresents the five most significant digits of the seconds fraction; that is, it represents the hundred thousandths of a second in a date and time value. While it is possible to display the hundred thousandths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.
ffffffRepresents the six most significant digits of the seconds fraction; that is, it represents the millionths of a second in a date and time value. While it is possible to display the millionths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.
fffffffRepresents the seven most significant digits of the seconds fraction; that is, it represents the ten millionths of a second in a date and time value. While it is possible to display the ten millionths of a second component of a time value, that value may not be meaningful. The precision of date and time values depends on the resolution of the system clock. On Windows NT 3.5 and later, and Windows Vista operating systems, the clock's resolution is approximately 10-15 milliseconds.
FRepresents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value. Nothing is displayed if the digit is zero.
:Represents the time separator defined in the current DateTimeFormatInfo..::.TimeSeparator property. This separator is used to differentiate hours, minutes, and seconds.
/ Represents the date separator defined in the current DateTimeFormatInfo..::.DateSeparator property. This separator is used to differentiate years, months, and days.
" Represents a quoted string (quotation mark). Displays the literal value of any string between two quotation marks ("). Your application should precede each quotation mark with an escape character (\).
 'Represents a quoted string (apostrophe). Displays the literal value of any string between two apostrophe (') characters.
%c Represents the result associated with a c custom format specifier, when the custom date and time format string consists solely of that custom format specifier. That is, to use the d, f, F, h, m, s, t, y, z, H, or M custom format specifier by itself, the application should specify %d, %f, %F, %h, %m, %s, %t, %y, %z, %H, or %M. For more information about using a single format specifier, see Using Single Custom Format Specifiers.

 

原文地址:http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Datetime 在C#中的用法 获取当前时间的各种格式
C#DateTime.ToString 格式化时间字符串和数值类型转换为字符串
C#占位符和格式化字符串
C# 四种九九乘法表
VB.NET 日期使用
c# 各种时间格式转换
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服