Datetime时间类型转换一览
复制代码
Console.WriteLine(DateTime.Now.ToString());
Console.WriteLine(DateTime.Now.ToShortDateString());
Console.WriteLine(DateTime.Now.ToShortTimeString());
Console.WriteLine(DateTime.Now.ToLongDateString());
Console.WriteLine(DateTime.Now.ToLongTimeString());
Console.WriteLine(DateTime.Now.Date);
Console.WriteLine(DateTime.Now.Day);
Console.WriteLine(DateTime.Now.DayOfWeek);
Console.WriteLine(DateTime.Now.DayOfYear);
Console.WriteLine(DateTime.Now.GetDateTimeFormats());
Console.WriteLine(DateTime.Now.Hour);
Console.WriteLine(DateTime.Now.Minute);
Console.WriteLine(DateTime.Now.Year);
Console.WriteLine(DateTime.Now.Kind);
Console.WriteLine(DateTime.Now.Millisecond);
Console.WriteLine(DateTime.Now.TimeOfDay);
Console.WriteLine(DateTime.Now.ToFileTime());
Console.WriteLine(DateTime.Now.ToFileTimeUtc());
Console.WriteLine(DateTime.Now.ToLocalTime());
Console.WriteLine(DateTime.Now.ToOADate());
Console.WriteLine(DateTime.Now.ToUniversalTime());
复制代码
结果:
DateTime时间格式转换大全
网友评论