DateTime properties
In this chapter you will learn:
DateTime parts
using System;//from java 2 s . co m
class MainClass
{
public static void Main()
{
DateTime myDateTime = DateTime.Now;
Console.WriteLine("myDateTime.Date = " + myDateTime.Date);
Console.WriteLine("myDateTime.Day = " + myDateTime.Day);
Console.WriteLine("myDateTime.DayOfWeek = " + myDateTime.DayOfWeek);
Console.WriteLine("myDateTime.DayOfYear = " + myDateTime.DayOfYear);
Console.WriteLine("myDateTime.Ticks = " + myDateTime.Ticks);
Console.WriteLine("myDateTime.TimeOfDay = " + myDateTime.TimeOfDay);
}
}
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Create a TimeSpan that represents a specified number of days
- Create a TimeSpan that represents a specified number of hours
- Returns a TimeSpan that represents a specified number of milliseconds
- Returns a TimeSpan that represents a specified number of minutes
Home » C# Tutorial » Date, Time, TimeZone