tengl
(Tomas Englundh)
1
Hi!
I would like to have a dynamic timestamp in milliseconds, eg. {{$timestampMs}}. Dynamic variables | Postman Learning Center
What I do now is setting a variable in Pre-request Script
pm.variables.set("timestampMs", new Date().getTime());
I don’t want to do that in every request i need a timestamp in ms.
I thought this would be a common case but I haven’t found any other requests for it.
1 Like
vdespa
(vdespa)
2
Unfortunately, there is no predefined Postman variable. But you can add this script to your collection and it will be available to all requests.
Each request will have a newly generated value.
1 Like
tengl
(Tomas Englundh)
3
Yes, thanks. That’s a bit better. A predefined variable would be preferable, but that will have to do.
1 Like
samweow
(samweow)
4
There is a pre-defined variable, you can access it like
const timestamp = pm.variables.replaceIn('{{$timestamp}}')
1 Like
Once a variable has been created and stored, it can be referenced in the body like this:
{
"time": "{{timestampMs}}"
}
2 Likes
thank you Danny
i have this body
how to use
1-“idRichiesta”: “00000062_00000320_1700497529”,
2- “timestamp”: 1700497529,
I don’t understand the question, how to use those where?
Do you want to extract those values from the request body and use them somewhere else?
You need to fully explain the use case and what you’re trying to achieve.
This should ideally be a separate question as this topic was already solved.
1 Like