C#| DateTime.GetDateTimeFormats()方法与示例
DateTime.GetDateTimeFormats()方法
DateTime.GetDateTimeFormats()方法用于获取所有可能的日期时间格式。
语法:
string[] DateTime.GetDateTimeFormates(DateTime dt);
Parameter(s):
DateTimedt–代表日期/时间。
返回值:
此方法的返回类型为string[],它返回包含所有可能的日期时间格式的字符串类的数组。
举例说明方法的例子DateTime.GetDateTimeFormats()
using System; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { DateTime dt1 = new DateTime(2019,1,1,10,10,10); string []str =dt1.GetDateTimeFormats(); foreach (string format in str) { Console.WriteLine(format); } Console.WriteLine(); } } }
输出结果
1/1/2019 1/1/19 01/01/19 01/01/2019 19/01/01 2019-01-01 01-Jan-19 Tuesday, January 01, 2019 January 01, 2019 Tuesday, 01 January, 2019 01 January, 2019 Tuesday, January 01, 2019 10:10 AM Tuesday, January 01, 2019 10:10 AM Tuesday, January 01, 2019 10:10 Tuesday, January 01, 2019 10:10 January 01, 2019 10:10 AM January 01, 2019 10:10 AM January 01, 2019 10:10 January 01, 2019 10:10 Tuesday, 01 January, 2019 10:10 AM Tuesday, 01 January, 2019 10:10 AM Tuesday, 01 January, 2019 10:10 Tuesday, 01 January, 2019 10:10 01 January, 2019 10:10 AM 01 January, 2019 10:10 AM 01 January, 2019 10:10 01 January, 2019 10:10 Tuesday, January 01, 2019 10:10:10 AM Tuesday, January 01, 2019 10:10:10 AM Tuesday, January 01, 2019 10:10:10 Tuesday, January 01, 2019 10:10:10 January 01, 2019 10:10:10 AM January 01, 2019 10:10:10 AM January 01, 2019 10:10:10 January 01, 2019 10:10:10 Tuesday, 01 January, 2019 10:10:10 AM Tuesday, 01 January, 2019 10:10:10 AM Tuesday, 01 January, 2019 10:10:10 Tuesday, 01 January, 2019 10:10:10 01 January, 2019 10:10:10 AM 01 January, 2019 10:10:10 AM 01 January, 2019 10:10:10 01 January, 2019 10:10:10 1/1/2019 10:10 AM 1/1/2019 10:10 AM 1/1/2019 10:10 1/1/2019 10:10 1/1/19 10:10 AM 1/1/19 10:10 AM 1/1/19 10:10 1/1/19 10:10 01/01/19 10:10 AM 01/01/19 10:10 AM 01/01/19 10:10 01/01/19 10:10 01/01/2019 10:10 AM 01/01/2019 10:10 AM 01/01/2019 10:10 01/01/2019 10:10 19/01/01 10:10 AM 19/01/01 10:10 AM 19/01/01 10:10 19/01/01 10:10 2019-01-01 10:10 AM 2019-01-01 10:10 AM 2019-01-01 10:10 2019-01-01 10:10 01-Jan-19 10:10 AM 01-Jan-19 10:10 AM 01-Jan-19 10:10 01-Jan-19 10:10 1/1/2019 10:10:10 AM 1/1/2019 10:10:10 AM 1/1/2019 10:10:10 1/1/2019 10:10:10 1/1/19 10:10:10 AM 1/1/19 10:10:10 AM 1/1/19 10:10:10 1/1/19 10:10:10 01/01/19 10:10:10 AM 01/01/19 10:10:10 AM 01/01/19 10:10:10 01/01/19 10:10:10 01/01/2019 10:10:10 AM 01/01/2019 10:10:10 AM 01/01/2019 10:10:10 01/01/2019 10:10:10 19/01/01 10:10:10 AM 19/01/01 10:10:10 AM 19/01/01 10:10:10 19/01/01 10:10:10 2019-01-01 10:10:10 AM 2019-01-01 10:10:10 AM 2019-01-01 10:10:10 2019-01-01 10:10:10 01-Jan-19 10:10:10 AM 01-Jan-19 10:10:10 AM 01-Jan-19 10:10:10 01-Jan-19 10:10:10 January 01 January 01 2019-01-01T10:10:10.0000000 2019-01-01T10:10:10.0000000 Tue, 01 Jan 2019 10:10:10 GMT Tue, 01 Jan 2019 10:10:10 GMT 2019-01-01T10:10:10 10:10 AM 10:10 AM 10:10 10:10 10:10:10 AM 10:10:10 AM 10:10:10 10:10:10 2019-01-01 10:10:10Z Tuesday, January 01, 2019 4:40:10 AM Tuesday, January 01, 2019 04:40:10 AM Tuesday, January 01, 2019 4:40:10 Tuesday, January 01, 2019 04:40:10 January 01, 2019 4:40:10 AM January 01, 2019 04:40:10 AM January 01, 2019 4:40:10 January 01, 2019 04:40:10 Tuesday, 01 January, 2019 4:40:10 AM Tuesday, 01 January, 2019 04:40:10 AM Tuesday, 01 January, 2019 4:40:10 Tuesday, 01 January, 2019 04:40:10 01 January, 2019 4:40:10 AM 01 January, 2019 04:40:10 AM 01 January, 2019 4:40:10 01 January, 2019 04:40:10 January, 2019 January, 2019