gpt4 book ai didi

c# - 如何可视化各种 DateTime 格式的显示方式?

转载 作者:行者123 更新时间:2023-11-30 13:13:23 24 4
gpt4 key购买 nike

我希望能够快速引用各种 DateTime 格式的显示方式,而不是开始一个费力的编辑、编译、gawk 和递归过程,直到满意为止。

最佳答案

这显示了当前区域性的所有格式:

StringBuilder sb = new StringBuilder();
foreach (string dateTimePattern in DateTimeFormatInfo.CurrentInfo.GetAllDateTimePatterns()) {
sb.AppendFormat("{0} = {1}\r\n", dateTimePattern, DateTime.Now.ToString(dateTimePattern));
}

之后的 StringBuilder 内容:

M/d/yyyy = 7/18/2012
M/d/yy = 7/18/12
MM/dd/yy = 07/18/12
MM/dd/yyyy = 07/18/2012
yy/MM/dd = 12/07/18
yyyy-MM-dd = 2012-07-18
dd-MMM-yy = 18-Jul-12
dddd, MMMM dd, yyyy = Wednesday, July 18, 2012
MMMM dd, yyyy = July 18, 2012
dddd, dd MMMM, yyyy = Wednesday, 18 July, 2012
dd MMMM, yyyy = 18 July, 2012
dddd, MMMM dd, yyyy h:mm tt = Wednesday, July 18, 2012 4:25 PM
dddd, MMMM dd, yyyy hh:mm tt = Wednesday, July 18, 2012 04:25 PM
dddd, MMMM dd, yyyy H:mm = Wednesday, July 18, 2012 16:25
dddd, MMMM dd, yyyy HH:mm = Wednesday, July 18, 2012 16:25
MMMM dd, yyyy h:mm tt = July 18, 2012 4:25 PM
MMMM dd, yyyy hh:mm tt = July 18, 2012 04:25 PM
MMMM dd, yyyy H:mm = July 18, 2012 16:25
MMMM dd, yyyy HH:mm = July 18, 2012 16:25
dddd, dd MMMM, yyyy h:mm tt = Wednesday, 18 July, 2012 4:25 PM
dddd, dd MMMM, yyyy hh:mm tt = Wednesday, 18 July, 2012 04:25 PM
dddd, dd MMMM, yyyy H:mm = Wednesday, 18 July, 2012 16:25
dddd, dd MMMM, yyyy HH:mm = Wednesday, 18 July, 2012 16:25
dd MMMM, yyyy h:mm tt = 18 July, 2012 4:25 PM
dd MMMM, yyyy hh:mm tt = 18 July, 2012 04:25 PM
dd MMMM, yyyy H:mm = 18 July, 2012 16:25
dd MMMM, yyyy HH:mm = 18 July, 2012 16:25
dddd, MMMM dd, yyyy h:mm:ss tt = Wednesday, July 18, 2012 4:25:17 PM
dddd, MMMM dd, yyyy hh:mm:ss tt = Wednesday, July 18, 2012 04:25:17 PM
dddd, MMMM dd, yyyy H:mm:ss = Wednesday, July 18, 2012 16:25:17
dddd, MMMM dd, yyyy HH:mm:ss = Wednesday, July 18, 2012 16:25:17
MMMM dd, yyyy h:mm:ss tt = July 18, 2012 4:25:17 PM
MMMM dd, yyyy hh:mm:ss tt = July 18, 2012 04:25:17 PM
MMMM dd, yyyy H:mm:ss = July 18, 2012 16:25:17
MMMM dd, yyyy HH:mm:ss = July 18, 2012 16:25:17
dddd, dd MMMM, yyyy h:mm:ss tt = Wednesday, 18 July, 2012 4:25:17 PM
dddd, dd MMMM, yyyy hh:mm:ss tt = Wednesday, 18 July, 2012 04:25:17 PM
dddd, dd MMMM, yyyy H:mm:ss = Wednesday, 18 July, 2012 16:25:17
dddd, dd MMMM, yyyy HH:mm:ss = Wednesday, 18 July, 2012 16:25:17
dd MMMM, yyyy h:mm:ss tt = 18 July, 2012 4:25:17 PM
dd MMMM, yyyy hh:mm:ss tt = 18 July, 2012 04:25:17 PM
dd MMMM, yyyy H:mm:ss = 18 July, 2012 16:25:17
dd MMMM, yyyy HH:mm:ss = 18 July, 2012 16:25:17
M/d/yyyy h:mm tt = 7/18/2012 4:25 PM
M/d/yyyy hh:mm tt = 7/18/2012 04:25 PM
M/d/yyyy H:mm = 7/18/2012 16:25
M/d/yyyy HH:mm = 7/18/2012 16:25
M/d/yy h:mm tt = 7/18/12 4:25 PM
M/d/yy hh:mm tt = 7/18/12 04:25 PM
M/d/yy H:mm = 7/18/12 16:25
M/d/yy HH:mm = 7/18/12 16:25
MM/dd/yy h:mm tt = 07/18/12 4:25 PM
MM/dd/yy hh:mm tt = 07/18/12 04:25 PM
MM/dd/yy H:mm = 07/18/12 16:25
MM/dd/yy HH:mm = 07/18/12 16:25
MM/dd/yyyy h:mm tt = 07/18/2012 4:25 PM
MM/dd/yyyy hh:mm tt = 07/18/2012 04:25 PM
MM/dd/yyyy H:mm = 07/18/2012 16:25
MM/dd/yyyy HH:mm = 07/18/2012 16:25
yy/MM/dd h:mm tt = 12/07/18 4:25 PM
yy/MM/dd hh:mm tt = 12/07/18 04:25 PM
yy/MM/dd H:mm = 12/07/18 16:25
yy/MM/dd HH:mm = 12/07/18 16:25
yyyy-MM-dd h:mm tt = 2012-07-18 4:25 PM
yyyy-MM-dd hh:mm tt = 2012-07-18 04:25 PM
yyyy-MM-dd H:mm = 2012-07-18 16:25
yyyy-MM-dd HH:mm = 2012-07-18 16:25
dd-MMM-yy h:mm tt = 18-Jul-12 4:25 PM
dd-MMM-yy hh:mm tt = 18-Jul-12 04:25 PM
dd-MMM-yy H:mm = 18-Jul-12 16:25
dd-MMM-yy HH:mm = 18-Jul-12 16:25
M/d/yyyy h:mm:ss tt = 7/18/2012 4:25:17 PM
M/d/yyyy hh:mm:ss tt = 7/18/2012 04:25:17 PM
M/d/yyyy H:mm:ss = 7/18/2012 16:25:17
M/d/yyyy HH:mm:ss = 7/18/2012 16:25:17
M/d/yy h:mm:ss tt = 7/18/12 4:25:17 PM
M/d/yy hh:mm:ss tt = 7/18/12 04:25:17 PM
M/d/yy H:mm:ss = 7/18/12 16:25:17
M/d/yy HH:mm:ss = 7/18/12 16:25:17
MM/dd/yy h:mm:ss tt = 07/18/12 4:25:17 PM
MM/dd/yy hh:mm:ss tt = 07/18/12 04:25:17 PM
MM/dd/yy H:mm:ss = 07/18/12 16:25:17
MM/dd/yy HH:mm:ss = 07/18/12 16:25:17
MM/dd/yyyy h:mm:ss tt = 07/18/2012 4:25:17 PM
MM/dd/yyyy hh:mm:ss tt = 07/18/2012 04:25:17 PM
MM/dd/yyyy H:mm:ss = 07/18/2012 16:25:17
MM/dd/yyyy HH:mm:ss = 07/18/2012 16:25:17
yy/MM/dd h:mm:ss tt = 12/07/18 4:25:17 PM
yy/MM/dd hh:mm:ss tt = 12/07/18 04:25:17 PM
yy/MM/dd H:mm:ss = 12/07/18 16:25:17
yy/MM/dd HH:mm:ss = 12/07/18 16:25:17
yyyy-MM-dd h:mm:ss tt = 2012-07-18 4:25:17 PM
yyyy-MM-dd hh:mm:ss tt = 2012-07-18 04:25:17 PM
yyyy-MM-dd H:mm:ss = 2012-07-18 16:25:17
yyyy-MM-dd HH:mm:ss = 2012-07-18 16:25:17
dd-MMM-yy h:mm:ss tt = 18-Jul-12 4:25:17 PM
dd-MMM-yy hh:mm:ss tt = 18-Jul-12 04:25:17 PM
dd-MMM-yy H:mm:ss = 18-Jul-12 16:25:17
dd-MMM-yy HH:mm:ss = 18-Jul-12 16:25:17
MMMM dd = July 18
MMMM dd = July 18
yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK = 2012-07-18T16:25:17.0961142-07:00
yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffffffK = 2012-07-18T16:25:17.0961142-07:00
ddd, dd MMM yyyy HH':'mm':'ss 'GMT' = Wed, 18 Jul 2012 16:25:17 GMT
ddd, dd MMM yyyy HH':'mm':'ss 'GMT' = Wed, 18 Jul 2012 16:25:17 GMT
yyyy'-'MM'-'dd'T'HH':'mm':'ss = 2012-07-18T16:25:17
h:mm tt = 4:25 PM
hh:mm tt = 04:25 PM
H:mm = 16:25
HH:mm = 16:25
h:mm:ss tt = 4:25:17 PM
hh:mm:ss tt = 04:25:17 PM
H:mm:ss = 16:25:17
HH:mm:ss = 16:25:17
yyyy'-'MM'-'dd HH':'mm':'ss'Z' = 2012-07-18 16:25:17Z
dddd, MMMM dd, yyyy h:mm:ss tt = Wednesday, July 18, 2012 4:25:17 PM
dddd, MMMM dd, yyyy hh:mm:ss tt = Wednesday, July 18, 2012 04:25:17 PM
dddd, MMMM dd, yyyy H:mm:ss = Wednesday, July 18, 2012 16:25:17
dddd, MMMM dd, yyyy HH:mm:ss = Wednesday, July 18, 2012 16:25:17
MMMM dd, yyyy h:mm:ss tt = July 18, 2012 4:25:17 PM
MMMM dd, yyyy hh:mm:ss tt = July 18, 2012 04:25:17 PM
MMMM dd, yyyy H:mm:ss = July 18, 2012 16:25:17
MMMM dd, yyyy HH:mm:ss = July 18, 2012 16:25:17
dddd, dd MMMM, yyyy h:mm:ss tt = Wednesday, 18 July, 2012 4:25:17 PM
dddd, dd MMMM, yyyy hh:mm:ss tt = Wednesday, 18 July, 2012 04:25:17 PM
dddd, dd MMMM, yyyy H:mm:ss = Wednesday, 18 July, 2012 16:25:17
dddd, dd MMMM, yyyy HH:mm:ss = Wednesday, 18 July, 2012 16:25:17
dd MMMM, yyyy h:mm:ss tt = 18 July, 2012 4:25:17 PM
dd MMMM, yyyy hh:mm:ss tt = 18 July, 2012 04:25:17 PM
dd MMMM, yyyy H:mm:ss = 18 July, 2012 16:25:17
dd MMMM, yyyy HH:mm:ss = 18 July, 2012 16:25:17
MMMM, yyyy = July, 2012
MMMM, yyyy = July, 2012

我不确定为什么会重复几种模式。

关于c# - 如何可视化各种 DateTime 格式的显示方式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11551655/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com