Need to add 2 years to ISO Timestamp to be used in request

I need to be able to add two years to my iso timestamp for my request body

I have this in my pre-request script

pm.collectionVariables.set(“timestamp”, pm.variables.replaceIn(‘{{$isoTimestamp}}’));

I need the timestamp in the future for an expiry date

The following seems to work.

let timeStamp = pm.variables.replaceIn("{{$isoTimestamp}}");
console.log(timeStamp);

let twoYearsFromNow = new Date(new Date(pm.variables.replaceIn("{{$isoTimestamp}}")).setFullYear(new Date().getFullYear() + 2)).toISOString();
console.log(twoYearsFromNow);

image

Cribbed from javascript - Add A Year To Today’s Date - Stack Overflow

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.