Display the Date, Day, DayOfWeek, DayOfYear, Ticks, and TimeOfDayProperties of DateTime : DateTime : Date Time C# Examples


C# Examples » Date Time » DateTime »

 

Display the Date, Day, DayOfWeek, DayOfYear, Ticks, and TimeOfDayProperties of DateTime









    
using  System;

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);



    }

}
    
   
  
   



Output

myDateTime.Date = 25/03/2007 12:00:00 AM
myDateTime.Day = 25
myDateTime.DayOfWeek = Sunday
myDateTime.DayOfYear = 84
myDateTime.Ticks = 633104295802812500
myDateTime.TimeOfDay = 14:26:20.2812500


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Date Time
» DateTime