How to add minutes to moment js while looping

So, I’m trying to add 15 minutes on each loop that I run.

let startDatesHours = moment("1200", "hmm").format("HH:mm:ss")

Now, for each run I want to add 15 minutes , so it would be 12:15 , 12:30 and so on…
However, I’m not certain how to approach this, it feels like a simple issue

I know how to add the minutes - .add(15, ‘minutes’), however I want to make it so, once it adds 15 minutes, it will be reusable on the following run and so on (18 runs roughly)
So I will be getting the variable on each run at the start and setting its new value at the end, but I cant figure out how to do it,

So I want to use pm.environment.get to get the initial value of 12:00, add 15 minutes , set the new value in the environment and run the request again, so when the pm.environment.get runs again, the value should be 12:15 and move to 12;30 for the next request

Should I be doing something like
let startDatesHours = moment(pm.environment.get('time'), "hmm").add(15, 'minutes').format("HH:mm:ss")

and update ‘time’ for each run?

Hi @theToncheff!

Here’s how I just did it:


var time = moment(pm.variables.get('time'));
console.log('Time: ' + time.format());

console.log('Time + 15: ' + time.format());


You could easily change pm.variables.<method> to pm.environment.<method> if you want.