'Insert timestamp without milliseconds (only 10 digits) in Postman
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!!
Solution 1:[1]
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 :
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

