1

I use moment.js to get UTC time in Postman.

The initial test will validate the format.

But as I go through the user journey and run more tests I need to get the same time but edit the format in order to validate it in later test cases.

Here is the prerequisite script I use for the initial test:

var moment = require('moment');
pm.globals.set("PnDStartTime", moment.utc());

var moment = require('moment');
pm.globals.set("PnDendTime+6", moment.utc().add(6, 'hours'));

So I was looking to format after the fact.

I know how to format the value, but not after it was set and moved.

n-verbitsky
  • 552
  • 2
  • 9
  • 20
dave lacey
  • 11
  • 1
  • Possible duplicate of [How do I format {{$timestamp}} as MM/DD/YYYY in Postman?](https://stackoverflow.com/questions/47355150/how-do-i-format-timestamp-as-mm-dd-yyyy-in-postman) – Alexis May 02 '19 at 13:23

1 Answers1

0

Have you looked at using .format("string") in that chain?

You can change the string value to the format you want.

All the information about moment can be found in thier docs:

https://momentjs.com/docs/

Danny Dainton
  • 23,069
  • 6
  • 67
  • 80