Get the date and time response (exclude "second")

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.

Hereโ€™s an outline with best practices for making your inquiry.

My question:
Hi all, I am still learning to use postman and sometimes I am confused what the keyword that I can use for searching the solution. Really need your help :slight_smile: here my issue:
I want to get the date&time from the response body, but only the date and for the time only want to get the hour & minutes (exclude โ€œsecondโ€)

NOTES: I want to save into variable

Example response that I want to get:

{
"is_true": true,
"datetime": "2019-08-24T14:15:22Z",
"data": {
"description": "Service OK",
"start_at": "2019-08-24T14:15:22Z",
"end_at": "2019-08-24T14:15:22Z"
}
}

Details (like screenshots):

How I found the problem:

Iโ€™ve already tried:

Hi,

So if this is the response you are getting

{
"is_true": true,
"datetime": "2019-08-24T14:15:22Z",
"data": {
"description": "Service OK",
"start_at": "2019-08-24T14:15:22Z",
"end_at": "2019-08-24T14:15:22Z"
}

Then you could get the date and the time from this and store them in variables.

// get the postman response
let res = pm.response.json();

// get the date
let date = res.datetime.split('T')[0];

// get the time 
let time = res.datetime.split('T')[1].slice(0,5);