How do I generate a timestamp and put it in a variable in jmeter?

Nikhil picture Nikhil · Nov 25, 2016 · Viewed 26.5k times · Source

How do I generate a timestamp and put it in a variable in jmeter? So that the variable can be passed in the URL.

Answer

Naveen Kumar R B picture Naveen Kumar R B · Nov 25, 2016

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

enter image description here

in View Results Tree

enter image description here


You can use Function Helper Dialog (in Options), to generate the code:

enter image description here

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