System Type Date Time Methods C# with Example



System Type Date Time Methods C# with Example

 using System;

namespace CSharpFundamentals
{
    class SystemTypeDateTimeMethods
    {
        private static void Main(string[] args)
        {
			DateTime today = DateTime.Now;
			
			Console.WriteLine("Same Date of Next Year is: {0}", today.AddYears(1));
			Console.WriteLine("Date of Tomorrow is: {0}\n", today.AddDays(1));
			
			Console.WriteLine("Time after 1 Hour would be : {0}", today.AddHours(1));
			Console.WriteLine("Time after 10 Minutes would be : {0}", today.AddMinutes(10));
			Console.WriteLine("Time after 50 Seconds would be : {0}", today.AddSeconds(50));
			Console.WriteLine("Time after 100 Milliseconds would be : {0}", today.AddMilliseconds(10));
			
			TimeSpan schedule = new TimeSpan(1,20,0);
			Console.WriteLine("Time after 1 Hour 20 Minutes would be : {0}", today.Add(schedule));
			Console.WriteLine("DateTime Format : {0}", today.GetDateTimeFormats());
		}
    }
}
 

0 Comment's

Comment Form