Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 478
Nikhil Avatar asked Nov 25 '16 11:11

Nikhil


People also ask

How to get the current timestamp in JMeter?

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?

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 JMeter calculate the time in milliseconds?

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:

What are JMeter functions and user variables?

JMeter Functions and User Variables. JMeter functions are special values that can populate fields of any Sampler or other element in a test tree.


Video Answer


1 Answers

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

like image 161
Naveen Kumar R B Avatar answered Sep 29 '22 19:09

Naveen Kumar R B