System Type Date Time Properties C# with Example

System Type Date Time Properties C# with Example

 using System;

namespace CSharpFundamentals
    class SystemTypeParseMethod
        private static void Main(string[] args)
			DateTime today = DateTime.Now;
			Console.WriteLine("Date Related Properties");
			Console.WriteLine("Today is: {0}", DateTime.Today);			
			Console.WriteLine("Date is: {0}", today.Date);			
			Console.WriteLine("Day is: {0}", today.Day);
			Console.WriteLine("Month is: {0}", today.Month);
			Console.WriteLine("Year is: {0}\n", today.Year);
			Console.WriteLine("Time Related Properties");
			Console.WriteLine("Hour is: {0}", today.Hour);
			Console.WriteLine("Minute is: {0}", today.Minute);
			Console.WriteLine("Second is: {0}", today.Second);
			Console.WriteLine("Millisecond is: {0}\n", today.Millisecond);
			Console.WriteLine("Kind of Date related Property");
			Console.WriteLine("Kind is: {0}\n", today.Kind);
			Console.WriteLine("Current Time related Properties");			
			Console.WriteLine("Now is: {0}", DateTime.Now);
			Console.WriteLine("UtcNow is: {0}\n", DateTime.UtcNow);
            Console.WriteLine("Start of Time Range is: {0}", DateTime.MinValue);
            Console.WriteLine("End of Time Range is: {0}\n", DateTime.MaxValue);

			Console.WriteLine("Date related other Properties");		
			Console.WriteLine("Day of Week is: {0}", today.DayOfWeek);
			Console.WriteLine("Day of Year is: {0}\n", today.DayOfYear);
			Console.WriteLine("Ticks related Properties");
			Console.WriteLine("Ticks till Current Time is: {0}", today.Ticks);
			Console.WriteLine("Minimum Ticks till Current Time is: {0}", DateTime.MinValue.Ticks);
			Console.WriteLine("Maximum Ticks till Current Time is: {0}", DateTime.MaxValue.Ticks);			

0 Comment's

Comment Form