How to Add Minutes in the Current Date Time in C# – Programming Code Examples
ASP.NET C#

How to Add Minutes in the Current Date Time in C#2 min read

The following asp.net c# example code demonstrate us how can we add minutes to a DateTime object programmatically at run time. .Net framework’s DateTime.AddMinutes() method allow us to add one more more minutes with a date time object.

DateTime.AddMinutes() method exists in System namespace. AddMinutes() method have a required parameter named ‘value’. This ‘value’ parameter value data type is System.Double which represent a number of whole and fractional minutes. This is very interesting that the ‘value’ parameter value can be negative or positive. So, technically we can also subtract minutes from a DateTime object.




DateTime.AddMinutes() method return value data type is System.DateTime. This return value is a DateTime object which is the sum of specified minutes passes by parameter and specified DateTime object. AddMinutes() method does not modify/change the provided DateTime object instead it return a new DateTime object that is the result of this operation.

The DateTime.AddMinutes() method through ArgumentOutOfRangeException, if the resulting DateTime is less than MinValue or greater than MaxValue.

Example: How to add minutes to DateTime in C#

asp.net date time example: how to add minutes(DateTime.Now.AddMinutes())

asp.net date time example: how to add minutes(DateTime.Now.AddMinutes())

ASP.NET Code:

 

Leave a Comment