jmeter- How to get current date and time in seconds

You can use __time() function, by default it returns current time in milliseconds since beginning of Unix epoch

If you need this time in "seconds" precision - just divide it by 1000 using i.e. __javaScript() function

So:

  • ${__time(,)} will return current time in milliseconds
  • ${__javaScript(${__time(,)} / 1000,)} - will return current time in seconds
  • ${__javaScript(Math.round(${__time(,)} / 1000),)} - will round up the current time in seconds to the nearest integer

Demo:

JMeter time javascript functions

Reference materials:

  • JMeter Functions and Variables
  • SimpleDateFormat patterns
  • How to Use JMeter Functions - Part III

Use __time function with format string as /1000.

 ${__time(/1000,)} - to get time in seconds

From JMeter DOCs:

For example, "/1000" returns the current time in seconds since the epoch.

Tags:

Jmeter