Unanswered question

Creating a timestamp in seconds rather than milliseconds

Seems a very simple scenario and I should be able to work it out but....

I can see how you create a timestamp variable that uses EPOCH value in milliseconds, i need to have one in seconds.

Similar questions say just divide by 1000 but where?

I have tried where i want to use the value in my request. In 'Advanced Parameters' just saying value is

${timestamp_since_1970}/1000

but that just puts that text in as

timestamp: 1631521522296/1000

What is the easiest way to quickly divide the milliseconds value by 1000 and use that?

David M.
David M.

David M.

Level
0
4 / 100
points

Answers

You would need some javascript for this, if you insert a js snippet and then just pass in your value, do the calculation, then return the value

code
---
var myVar = context.variableManager.getValue("time_in_millis");

logger.debug("millis="+myVar);

var secs = parseInt(myVar)/1000;

logger.debug("millis to secs="+secs);

context.variableManager.setValue("time_in_secs",secs);
---
result

millis=1631524901855
millis to secs=1631524901.855