DateTime currentTime = DateTime.Now; DateTime newTime = currentTime.AddSeconds(5);
DateTime startTime = new DateTime(2021, 01, 01, 0, 0, 0); DateTime endTime = startTime.AddSeconds(3600);This example sets a start time to January 1st, 2021 at 12:00:00 am and adds 3600 seconds (or one hour) to it to determine the end time. Package library: This method is a part of the C# System namespace library, so no additional package installation is required.