c# datetime.
DateTime.TimeOfDay属性 (DateTime.TimeOfDay Property)
DateTime.TimeOfDay Property is used to get the time of the day of this object. It's a GET property of DateTime class.
DateTime.TimeOfDay属性用于获取该对象一天中的时间。 这是DateTime类的GET属性。
Syntax:
句法:
TimeSpan DateTime.Year;
Return value:
返回值:
The return type of this Property is TimeSpan, it returns the time of the day of this object.
该属性的返回类型为TimeSpan ,它返回该对象当天的时间。
Example to demonstrate example of DateTime.TimeOfDay Property
示例,以演示DateTime.TimeOfDay属性的示例
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//creating an object of DateTime class
//and, initializing it with the current time
//using "Now"
DateTime dt = DateTime.Now;
//getting the time of the day
string time = dt.TimeOfDay.ToString();
//printing current date & time
Console.WriteLine("Current date & time is: " + dt.ToString());
//printing the day of the week
Console.WriteLine("The time is : " + time);
//just to print a new line
Console.WriteLine();
}
}
}
Output
输出量
Current date & time is: 10/24/2019 8:23:35 AM
The time is : 08:23:35.9734600
翻译自: https://www.includehelp.com/dot-net/datetime-timeofday.aspx
c# datetime.