Hi, so I’m stuck on creating a new variable for a past date. I currently have a global variable:
pm.globals.set(“todayDate”,parseInt(moment().format(“YYYYMMDD”)))
Instead of creating a bunch of different global variables for 5 days back, 10 days back and so on I was wondering what I can do with my todayDate variable to set a new local variable as 10 days back?
I know i could just do something like this: pm.globals.set(“yesterdayDate”,parseInt(moment().subtract(1, ‘days’).format(“YYYYMMDD”)))
but was thinking i could use my todayDate variable and manipulate that ?
Hi @bpricilla the method “substract” is not working for me . I’m getting the error: your variable.substract is not a function….
Please advice!
// 1. Create a moment object for now
let now = require('moment');
const time = now().format(("YYYY-MM-DD") + "T" + ("HH:mm:ss")).split("+02:00")[0] + ".000Z";
//2. put this in the environment variable to be able to reuse this in as much places as possible
pm.environment.set('currentDate', time);
let momentPodPrevious = now();
let prevResultpod = momentPodPrevious.substract('days', 1);
pm.environment.set('momentPodPrev', prevResultpod);