Have to include "Start Date" and "End Date" in my query to a REST API, need some help calling todays date in the JSON body

ey all,
Have to give
Start and End date to the API query to get back any data, and would like it to automatically use thodays date as the end datre, and 12 hours before as the start. The format I have to give the date in is like so, '2022-01-01T00:00:00Z'. I imagine I use transformers to make it the current date/time.

Thanks guys

you can do this with pure javascript or the moment library probably has options too, the format you're after is ISO standard

let currentDate = new Date();
let endDate = currentDate.toISOString(); //'2023-02-06T13:59:34.883Z'
currentDate.setHours(currentDate.getHours() -12);
let startDate = currentDate.toISOString(); //'2023-02-06T01:59:34.883Z'
1 Like