您的位置:首页 > 编程语言 > C#

C# 日期格式控制大全

2006-07-13 15:57 453 查看
当前时间:2005-11-3 18:31:30

Date = 2005-11-3 0:00:00
Day = 3
DayOfWeek = Thursday
DayOfYear = 307
Hour = 18
Millisecond = 171
Minute = 31
Month = 11
Second = 30
Ticks = 632666394901718750
TimeOfDay = 18:31:30.1718750
ToFileTime = 127754874901718750
ToFileTimeUtc = 127755162901718750
ToLocalTime = 2005-11-4 2:31:30
ToLongDateString = 2005年11月3日
ToLongTimeString = 18:31:30
ToOADate = 38659.7718769792
ToShortDateString = 2005-11-3
ToShortTimeString = 18:31
ToUniversalTime = 2005-11-3 10:31:30

DateTime d = DateTime.Now;
Response.Write("当前时间:" + d.ToString() + "<BR><BR>");
Response.Write("Date = " + d.Date.ToString() + "<BR>");
Response.Write("Day = " + d.Day.ToString() + "<BR>");
Response.Write("DayOfWeek = " + d.DayOfWeek.ToString() + "<BR>");
Response.Write("DayOfYear = " + d.DayOfYear.ToString() + "<BR>");
Response.Write("Hour = " + d.Hour.ToString() + "<BR>");
Response.Write("Millisecond = " + d.Millisecond.ToString() + "<BR>");
Response.Write("Minute = " + d.Minute.ToString() + "<BR>");
Response.Write("Month = " + d.Month.ToString() + "<BR>");
Response.Write("Second = " + d.Second.ToString() + "<BR>");
Response.Write("Ticks = " + d.Ticks.ToString() + "<BR>");
Response.Write("TimeOfDay = " + d.TimeOfDay.ToString() + "<BR>");
Response.Write("ToFileTime = " + d.ToFileTime().ToString() + "<BR>");
Response.Write("ToFileTimeUtc = " + d.ToFileTimeUtc().ToString() + "<BR>");
Response.Write("ToLocalTime = " + d.ToLocalTime().ToString() + "<BR>");
Response.Write("ToLongDateString = " + d.ToLongDateString() + "<BR>");
Response.Write("ToLongTimeString = " + d.ToLongTimeString() + "<BR>");
Response.Write("ToOADate = " + d.ToOADate().ToString() + "<BR>");
Response.Write("ToShortDateString = " + d.ToShortDateString() + "<BR>");
Response.Write("ToShortTimeString = " + d.ToShortTimeString() + "<BR>");
Response.Write("ToUniversalTime = " + d.ToUniversalTime() + "<BR>");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: