C# DateTime.Today屬性代碼示例- 純淨天空
文章推薦指數: 80 %
C# DateTime.Today屬性代碼示例,System.DateTime.Today用法.
當前位置:首頁>>代碼示例>>C#>>正文
本文整理匯總了C#中System.DateTime.Today屬性的典型用法代碼示例。
如果您正苦於以下問題:C#DateTime.Today屬性的具體用法?C#DateTime.Today怎麽用?C#DateTime.Today使用的例子?那麽恭喜您,這裏精選的屬性代碼示例或許可以為您提供幫助。
您也可以進一步了解該屬性所在類System.DateTime的用法示例。
在下文中一共展示了DateTime.Today屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。
您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的C#代碼示例。
示例1:Main
點讚15
//引入命名空間
usingSystem;
publicclassExample
{
publicstaticvoidMain()
{
//Getthecurrentdate.
DateTimethisDay=DateTime.Today;
//Displaythedateinthedefault(general)format.
Console.WriteLine(thisDay.ToString());
Console.WriteLine();
//Displaythedateinavarietyofformats.
Console.WriteLine(thisDay.ToString("d"));
Console.WriteLine(thisDay.ToString("D"));
Console.WriteLine(thisDay.ToString("g"));
}
}開發者ID:.NET開發者,項目名稱:System,代碼行數:18,代碼來源:DateTime.Today輸出:
5/3/201212:00:00AM
5/3/2012
Thursday,May03,2012
5/3/201212:00AM
示例2:Main
點讚14
//引入命名空間
usingSystem;
usingSystem.Globalization;
classMainClass{
publicstaticvoidMain(){
Console.WriteLine("CurrentDateandTime:{0}",DateTime.Now.ToString());
Console.WriteLine("CurrentDateOnly:{0}",DateTime.Today.ToString());
}
}開發者ID:C#程序員,項目名稱:System,代碼行數:12,代碼來源:DateTime.Today
注:本文中的System.DateTime.Today屬性示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。
相關方法
DateTime.DateTime()
DateTime.MaxValue
DateTime.MinValue
DateTime.Date
DateTime.Day
DateTime.DayOfWeek
DateTime.DayOfYear
DateTime.Hour
DateTime.Kind
DateTime.Millisecond
DateTime.Minute
DateTime.Month
DateTime.Now
DateTime.Second
DateTime.Ticks
DateTime.TimeOfDay
DateTime.Today
DateTime.UtcNow
DateTime.Year
DateTime.Add()
DateTime.AddDays()
DateTime.AddHours()
DateTime.AddMilliseconds()
DateTime.AddMinutes()
DateTime.AddMonths()
DateTime.AddSeconds()
DateTime.AddYears()
DateTime.Compare()
DateTime.DaysInMonth()
DateTime.Equals()
DateTime.FromBinary()
DateTime.FromFileTime()
DateTime.GetDateTimeFormats()
DateTime.IsDaylightSavingTime()
DateTime.IsLeapYear()
DateTime.Parse()
DateTime.ParseExact()
DateTime.SpecifyKind()
DateTime.Subtract()
DateTime.ToBinary()
DateTime.ToFileTime()
DateTime.ToLocalTime()
DateTime.ToLongDateString()
DateTime.ToLongTimeString()
DateTime.ToShortDateString()
DateTime.ToShortTimeString()
DateTime.ToString()
DateTime.ToUniversalTime()
DateTime.TryParse()
DateTime.TryParseExact()
DateTime.Addition()
DateTime.Equality()
DateTime.Subtraction()
延伸文章資訊
- 1C# DateTime.Today (Current Day With Zero Time) - Dot Net ...
DateTime.Today returns just the day—without the time. This is different from DateTime.Now, which ...
- 2Working with Date and Time in C# - TutorialsTeacher
C# includes DateTime struct to work with dates and times. To work with date and ... Today; // ret...
- 3【C#】《DateTime》獲取時間到毫秒的方式(今天、昨天、明天
說明: 來看看C#獲取時間到毫秒的方式(今天、昨天、明天、日期比大小) /*獲取今天日期(只有日期)*/DateTime GetNowDate = DateTime.Today; Outp.
- 4How do I get today's date in C# in mm/dd/yyyy format? - Stack ...
string today = DateTime.Today.ToString("M/d");.
- 5C# DateTime Format:Working with Date &Time format in C#|
This blog describes how to format DateTime in C# with a code sample. ... We can easily convert it...