Time Zone future date - Postman

pm.sendRequest(“http://worldtimeapi.org/api/timezone/Europe/Rome”, function (err, res) {
pm.globals.set(“localTimeRome”, res.json().datetime);

How to increase the number of days after reading the date from this api ?
Future date
previous date
future year


I would use “moment” with the offset from that request to get future date, previous date and future year. You can use (.format) at the end to format the result to whatever you need.

var moment = require('moment');

pm.sendRequest('http://worldtimeapi.org/api/timezone/Europe/Rome', function (err, res) {
// Set Rome Date/Time for Today    
pm.globals.set('localTimeRomeToday', moment.utc().utcOffset(res.json().utc_offset));
// Set Rome Date/Time for Yesterday  
pm.globals.set('localTimeRomeYesterday', moment.utc().utcOffset(res.json().utc_offset).subtract(1, 'day'));
// Set Rome Date/Time for Tomorrow 
pm.globals.set('localTimeRomeTomorrow', moment.utc().utcOffset(res.json().utc_offset).add(1, 'day'));
// Set Rome Date/Time for Next Year  
pm.globals.set('localTimeRomeNextYear', moment.utc().utcOffset(res.json().utc_offset).add(1, 'year'));


1 Like

@Mick, Thank you. code is working.