直接上代码
static void Main(string[] args) { DateTime time = DateTime.Now; Console.WriteLine("ToFileTime:"+time.ToFileTime()); Console.WriteLine("ToLocalTime:"+time.ToLocalTime()); Console.WriteLine("ToLongDateString:"+time.ToLongDateString()); Console.WriteLine("ToLongTimeString:"+time.ToLongTimeString()); Console.WriteLine("ToOADate:"+time.ToOADate()); Console.WriteLine("ToShortDateString:"+time.ToShortDateString()); Console.WriteLine("ToShortTimeString:"+time.ToShortTimeString()); Console.WriteLine("ToString:"+time.ToString()); Console.ReadLine(); }
结果:
ToFileTime:131432281146049537 ToLocalTime:2017/6/30 0:41:54 ToLongDateString:2017年6月30日 ToLongTimeString:0:41:54 ToOADate:42916.029104213 ToShortDateString:2017/6/30 ToShortTimeString:0:41 ToString:2017/6/30 0:41:54
想要哪个取哪个