im trying to create a parameter in Jmeter that gives the current timestamp + 5 minutes. Does anyone know how to do this? To generate the current timestamp i have this: ${__time(HH:mm:ss,TIMESTAMP)}
Variables are local to a thread; properties are common to all threads, and need to be referenced using the __P or __property function. When using \ before a variable for a windows path for example C:\test\${test}, ensure you escape the \ otherwise JMeter will not interpret the variable, example: C:\\test\\${test}.
The timestamp format is used for both writing and reading files. If the format is set to "ms", and the column does not parse as a long integer, JMeter (2.9+) will try the following formats: yyyy/MM/dd HH:mm:ss.
I'm afraid that __time() function doesn't provide enough flexibility. You'll need to calculate this date value via Beanshell Sampler or Beanshell Pre Processor
Relevant Beanshell code will look like
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
Date now = new Date(); // get current time
Calendar c = Calendar.getInstance(); // get Java Calendar instance
c.setTime(now); // set Calendar time to now
c.add(Calendar.MINUTE, 5); // add 5 minutes to current time
Date now_plus_5_minutes = c.getTime(); // get Date value for amended time
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); // create a formatter for date
String mydate = sdf.format(now_plus_5_minutes); // format date as string
vars.put("mydate",mydate); // save date to JMeter variable named "mydate"
You'll be able to refer that mydate
value as
In the place you'll need to provide that updated date.
Hope this helps.
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