I am currently using '${__time()}' function which returns the current time in milliseconds. However, I want something like this - Date Input 'mm/dd/yyyy' and Function Output '1504290600'. can somebody please help me. Note: I want output as Linux time and not in other formats as other questions already have.
Asked
Active
Viewed 447 times
1 Answers
1
Out of box JMeter doesn't provide this functionality, you will need a custom script for this, I would recommend using JSR223 Test Elements or Groovy function for this
Example code would be something like:
${__groovy(new Date().parse("MM/dd/yyyy"\, "09/04/2017").getTime(),)}
Or in case of non-functions:
def timestamp = new Date().parse("MM/dd/yyyy", "09/04/2017").getTime()
log.info('Required time is: ' + timestamp)
- Replace
09/04/2017
with the date of your choice - Remember that month pattern is capital
M
, lower casem
is for minutes. See SimpleDateFormat class reference for details - The above construction is available due to Groovy JDK Enhancements, you won't be able to use it in Java or Beanshell
- See Apache Groovy - Why and How You Should Use It article for more details on Groovy scripting in JMeter tests.

Dmitri T
- 159,985
- 5
- 83
- 133
-
Thanks, it works! – Jay Mehta Sep 16 '17 at 08:39