Overview
Returns sum of specified dateTime and timespan string.DateTimeOffset Calendar.AddTimeSpan(dateTime: DateTimeOffset, duration: string)
Arguments
DateTimeOffset dateTime
Specifies the base date time value.
string duration
The time parameter is in the "d.hh:mm:ss" or,ISO-8601,duration format
Remarks
Please make sure that you are using the right calendar object, since adding time is related with your calendar of choice. You can have more info on Calendar definitions by checking the$Calendarobject.
Example
//Adds exactly 1 day, 2 hours, 30 minutes and 45 seconds to the current time. var newDate = $Calendar.StandardCalendar.AddTimeSpan($Calendar.Today, '1.02:30:45'); var newDate = $Calendar.StandardCalendar.AddTimeSpan($Calendar.Today, 'P1DT2H');
Examples
//Adds exactly 1 day, 2 hours, 30 minutes and 45 seconds to the current time. var newDate = $Calendar.StandardCalendar.AddTimeSpan($Calendar.Today, '1.02:30:45'); var newDate = $Calendar.StandardCalendar.AddTimeSpan($Calendar.Today, 'P1DT2H');