JMeter – Current date and time in seconds


How to generate epoch timestamp in seconds in JMeter script?


JMeter function time() generates timestamp in epoch format in milliseconds i.e. 13 digits numbers like 1559815879767. Sometimes there is a requirement to pass the current timestamp in second i.e. 10 digits numbers like 1559815879. Some performance testers use BeanShell code to convert epoch timestamp (which is in milliseconds) to seconds. Just to recall, try to avoid the use of BeanShell or Groovy coding unless you have an alternate way.

There is a simple way to generate the timestamp in seconds in the JMeter script. Instead of writing BeanShell or Groovy code, you can use the below statement where you want to pass the timestamp in a second:


Refer to the screenshot showing epoch timing in milliseconds and seconds:

JMeter Time in seconds
Figure 01: Generation of epoch time in second

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 the below statement:


“testTimeStamp” is a variable which stores the value generated by the time() function in seconds.

You may be interested:

2 thoughts on “JMeter – Current date and time in seconds”

Leave a Comment