I am trying to set a variable in a collection which will pass the value of a time and date stamp 180 days in the past from today. Eg. Today is 15th June 2023, I want the format to be: YYYY-MM-DDTHH:mm:SS. The returned value should be: 2022-12-17T13:58:12
Can you please also explain how I would need to setup the variables in the Collection
So far this is what I have managed to do but it doesnt work.
Pre-request Script:
var moment = require(‘moment’)
pm.variables.set(‘timestamp’, moment().format((“YYYY-MM-DDTHH:mm:SS”)));
This is the error when I try and run a GET request:
The only Variable I have is:
timestamp
There are no values against this.
Apologies, I am quite new to this and trying to read and learn but this coding is quite complex to me. Any help is much appreciated.