You need to pass in the response timestamp to the moment function.
For example.
let responseTimestamp = "2023-07-28T11:51:39+00:00";
// you need to retrieve this element from your response
const moment = require("moment");
let timestamp1 = moment(responseTimestamp).format("YYYYMMDD");
console.log(timestamp1); // "20230728"
pm.collectionVariables.set("timestamp1", timestamp1);
let timestamp2 = moment(responseTimestamp).format("hhmmss"); // needs to be lowercase
console.log(timestamp2); // "115139"
pm.collectionVariables.set("timestamp2", timestamp2);