DateTimeOffset currentDateTime = DateTimeOffset.Now; DateTimeOffset newDateTime = currentDateTime.AddMonths(2);
DateTimeOffset currentDateTime = DateTimeOffset.Now; DateTimeOffset newDateTime = currentDateTime.AddMonths(-3);In this example, we get the current date and time and subtract 3 months from it using the AddMonths method. The new date and time value is stored in the newDateTime variable. These examples use the System namespace, which is included in the .NET framework. Therefore, no additional package library is required.