DateTime.GetDateTimeFormats() 方法
DateTime.GetDateTimeFormats() 方法用于获取所有可能的日期时间格式。
用法:
string[] DateTime.GetDateTimeFormates(DateTime dt);
参数:
DateTime dt
– 它代表日期/时间。
返回值:
这个方法的返回类型是string[]
,它返回包含所有可能的日期时间格式的字符串类数组。
示例演示 DateTime.GetDateTimeFormats() 方法的示例
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//Create object of datetime class
DateTime dt1 = new DateTime(2019,1,1,10,10,10);
//Get all date time formate in string array.
string []str =dt1.GetDateTimeFormats();
//Print all formates.
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
相关用法
- C# DateTime.GetDateTimeFormats()方法用法及代码示例
- C# DateTime.GetTypeCode()用法及代码示例
- C# DateTime.GetHashCode()用法及代码示例
- C# DateTime.ToFileTime()用法及代码示例
- C# DateTime.CompareTo()用法及代码示例
- C# DateTime.Add()用法及代码示例
- C# DateTime.AddSeconds()用法及代码示例
- C# DateTime.DaysInMonth()用法及代码示例
- C# DateTime.FromFileTime()用法及代码示例
- C# DateTime.Subtract()用法及代码示例
- C# DateTime.ToLocalTime()用法及代码示例
- C# DateTime.ToLongDateString()用法及代码示例
- C# DateTime.ToUniversalTime()用法及代码示例
- C# DateTime.SpecifyKind()用法及代码示例
- C# DateTime.FromBinary()用法及代码示例
- C# DateTime.ToFileTimeUtc()用法及代码示例
- C# DateTime.ToOADate()用法及代码示例
- C# DateTime.AddYears()用法及代码示例
- C# DateTime.IsDaylightSavingTime()用法及代码示例
- C# DateTime.AddTicks()用法及代码示例
注:本文由纯净天空筛选整理自 C# | DateTime.GetDateTimeFormats() Method with Example。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。