Console.WriteLine(string.Format("ToLongDateString:{0}", DateTime.Now.ToLongDateString())); Console.WriteLine(string.Format("ToLongTimeString:{0}", DateTime.Now.ToLongTimeString())); Console.WriteLine(string.Format("ToOADate:{0}", DateTime.Now.ToOADate())); Console.WriteLine(string.Format("ToShortDateString:{0}", DateTime.Now.ToShortDateString())); Console.WriteLine(string.Format("ToShortTimeString:{0}", DateTime.Now.ToShortTimeString())); Console.WriteLine(string.Format("ToString:{0}", DateTime.Now.ToString())); Console.WriteLine(string.Format("ToString(\"yyyy - MM - dd HH:mm:ss.ffff\"):{0}", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.ffff")));
运行结果:
ToLongDateString:2017年9月21日
ToLongTimeString:16:02:30
ToOADate:42999.6684130671
ToShortDateString:2017/9/21
ToShortTimeString:16:02
ToString:2017/9/21 16:02:30
ToString("yyyy - MM - dd HH:mm:ss.ffff"):2017-09-21 16:02:30.8921
来源:https://www.cnblogs.com/MXJ-Blogs/p/7569089.html