JavaScript method: XMLDate.addDuration()

This method returns an XMLDate object containing the new date/time after adding the duration from the duration argument.

Syntax

XMLDate.addDuration( duration );

Arguments

The following arguments are valid for this function:

Argument Data type Required Description
duration ISO 8601 duration string Yes This argument contains the ISO 8601 duration string or variable value you want the script to add to an XMLDate object.

Return values

An XMLDate object or null.

The method returns an XMLDate object or null if conversion fails.

Example

This example does the following:

  • Creates a new XMLDate object containing today's date
  • Adds 1 year, 2 months, 3 days, and 4 hours to the XMLDate object then displays the result
print( "Creating XMLDate object..." );
var d = new XMLDate( new Date() );
print( "The value of the new XMLDate object is: " + d );
print( "Adding 1 year, 2 months, 3 days, and 4 hours to date..." );
var dur = d.addDuration( "P1Y2M3DT4H" );
print( "The value of the new XMLDate object is: " + dur );