Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add more time into current timestamp of Postman?

Tags:

postman

I know I am able to add current timestamp into Request like this:

postman.setEnvironmentVariable('pickUpTime',(new Date()).toISOString());

However, I want to add 10min later to the current timestamp of Postman. How can I do that?

Seems I am not able to do it like this:

postman.setEnvironmentVariable('pickUpTime',(new Date() + 10000).toISOString());

like image 311
Hesam Avatar asked Apr 03 '18 19:04

Hesam


Video Answer


1 Answers

You can use the add function of moment.js within Postman, it makes this type of thing so simple and easy to manage.

var moment = require("moment")

pm.environment.set('pickUpTime', moment().add(10, 'minutes').toISOString())

This will set this value to an environment variable, using the the newer syntax.

like image 185
Danny Dainton Avatar answered Oct 19 '22 17:10

Danny Dainton