POST Date and Time to endpoint?

Hi,

I´m new to use Postman.

I´m currently try to call a POST request to my endpoint via JSON, return a JSON, but the data / time seems like the issue.

I would like to have a global parameter for:

  • Time
  • Date
  • DateTime

What I tried so far for this:
image

image

But I got also no error message, only a Status = 500 ?

Hey Vished,

If you want a global variable, you could try this in Pre-request Script:

let current = new Date();
let cDate = current.getFullYear() + '-' + (current.getMonth() + 1) + '-' + current.getDate();
let cTime = current.getHours() + ":" + current.getMinutes() + ":" + current.getSeconds();
let dateTime = cDate + ' ' + cTime;

pm.globals.set("current_date", dateTime);

1 Like