How to do substring on a API response

Hi. I am using this in my Test Script to visualize the response:

<table class="tftable" border="1">
        <tr>
            <th>Response 1</th>
            <th>Response 2</th>
            <th>Response 3</th>
        </tr>
        
        {{#each response}}
            <tr>
                <td>{{response_1}}</td>
                <td>{{response_2}}</td>
                <td>{{response_3}}</td>
            </tr>
        {{/each}}
    </table>

If {{response_1}} always returns the date and time in this format: 2020-08-20T12:45:14.245Z
how can I split date and time into their own columns, removing the T and Z?

I know I need to do something like this:
var respOne = {{response_1}};
var getDate = respOne.substring(0,10);
var getTime = respOne.substring(11,23);

I can then use getDate in the date cell and getTime in the time cell. I am just not sure of the correct syntax to use between the td tags.

I do something like that by modifying the initial response data before passing it into the visualizer.

You can try my example which utilize the Postman Echo endpoint with this collection https://www.getpostman.com/collections/5b1fccee7bcacb573ad0 or take it from the following code blocks.

Example data:

[
	{
		"response_1": "2020-08-20T12:45:14.245Z",
		"response_2": "some text",
		"response_3": "more text"
	},
	{
		"response_1": "2020-08-20T12:45:14.245Z",
		"response_2": "another text",
		"response_3": "placeholder"
	}
]

Code for the Test tab:

var responseDataModified = pm.response.json().data; // the content sent to the Echo endpoint is nested into the property 'data'
responseDataModified.forEach(entry => {
    // convert former string into object, may create and use another new property if you like to keep the original value as well
    entry.response_1 = {
        day: entry.response_1.substring(0, 10),
        time: entry.response_1.substring(11, 19)
    };
});

var template = `
<table class="tftable" border="1">
        <tr>
            <th>Response 1 (Day)</th>
            <th>Response 1 (Time)</th>
            <th>Response 2</th>
            <th>Response 3</th>
        </tr>
        
        {{#each response}}
            <tr>
                <td>{{response_1.day}}</td>
                <td>{{response_1.time}}</td>
                <td>{{response_2}}</td>
                <td>{{response_3}}</td>
            </tr>
        {{/each}}
    </table>
`;

pm.visualizer.set(template, {response: responseDataModified});

Let me know if that solves your problem.

Yes. This is great. Thank you.
It wasn’t working initially, but if I use this line then it works:

var responseDataModified = pm.response.json();

Very good. Great that it works now.