
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
DateTimeOffset.AddMinutes() Method in C#
The DateTimeOffset.AddMinutes() method in C# is used to adds a specified number of whole and fractional minutes to the value of this instance.
Syntax
Following is the syntax −
public DateTimeOffset AddMinutes (double val);
Above, Val is the number of minutes to be added. To subtract, set a negative value for minutes.
Example
Let us now see an example to implement the DateTimeOffset.AddMinutes() method −
using System; public class Demo { public static void Main() { DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 08, 10, 4, 20, 10, new TimeSpan(-5, 0, 0)); Console.WriteLine("DateTimeOffset (before adding minutes) = {0}", dateTimeOffset); DateTimeOffset res = dateTimeOffset.AddMinutes(15); Console.WriteLine("DateTimeOffset (after adding minutes) = {0}", res); } }
Output
This will produce the following output −
DateTimeOffset (before adding minutes) = 8/10/2019 4:20:10 AM -05:00 DateTimeOffset (after adding minutes) = 8/10/2019 4:35:10 AM -05:00
Example
Let us now see another example to implement the DateTimeOffset.AddMinutes() method −
using System; public class Demo { public static void Main() { DateTimeOffset dateTimeOffset = new DateTimeOffset(2019, 08, 10, 4, 20, 10, new TimeSpan(-5, 0, 0)); Console.WriteLine("DateTimeOffset (before subtracting minutes) = {0}", dateTimeOffset); DateTimeOffset res = dateTimeOffset.AddMinutes(-15); Console.WriteLine("DateTimeOffset (after subtracting minutes) = {0}", res); } }
Output
This will produce the following output −
DateTimeOffset (before subtracting minutes) = 8/10/2019 4:20:10 AM -05:00 DateTimeOffset (after subtracting minutes) = 8/10/2019 4:05:10 AM -05:00
Advertisements