1

I have this in my pre-request script:

var moment = require("moment");
postman.setEnvironmentVariable("current_timestamp", moment().add(10, 'seconds').valueOf());

This returns 13 digit value for timestamp,But my server only accepts upto 10 digits (until seconds) and after this i want to pass the 10 digit value in my request body :

  "carid": "c1234",
  "timestamp":{{current_timestamp}},
  "lastCoordinates": {
    "uuid": "2df38805-b0f8-4f8f-947e-c53e98d63ff6",

Any help is greatly appreciated!!

mskfisher
  • 3,291
  • 4
  • 35
  • 48
alam mand
  • 11
  • 1
  • 2

1 Answers1

2
moment().add(10, 'seconds').unix()

use epoch time stamp using unix()

What you are getting in value of is the unix millisecond time stamp which is 13 digit , if you want 10 digit get epoch time

https://momentjs.com/docs/#/parsing/string-format/

Note that this will have time in second format and doesn't consist of millisecond part;

output :

enter image description here

PDHide
  • 18,113
  • 2
  • 31
  • 46