How do I generate a timestamp and put it in a variable in jmeter? So that the variable can be passed in the URL.
If you want to get the current timestamp in your local time zone - go for __time () function: If you're in the different time zone and would like to get the current timestamp in UTC - go for __groovy () function: More information on JMeter Functions concept: Apache JMeter Functions - An Introduction
How do I generate a timestamp and put it in a variable in jmeter? So that the variable can be passed in the URL. Show activity on this post. you can refer the value using $ {curTime} in later requests. Note: you can also save the value using name of the variable (second row), so later you can refer the same value.
How does it work?: When you use $ {__time (/1000,)} then JMeter divides the timestamp (which is in milliseconds) by 1000 and passes in the request (in seconds). If you want to save the timestamp in a variable then use below statement:
JMeter Functions and User Variables. JMeter functions are special values that can populate fields of any Sampler or other element in a test tree.
Add the following function wheerever you want to send the Unix based timestamp:
${__time(,curTime)}
you can refer the value using ${curTime}
in later requests.
Example:
HTTP Sampler
in View Results Tree
You can use Function Helper Dialog (in Options), to generate the code:
Note: you can also save the value using name of the variable
(second row), so later you can refer the same value.
Note: you can also format the time, based on your needs (first row).
Reference:
http://jmeter.apache.org/usermanual/functions.html#__time
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With