Skip to content

__timeShift

JMeter __timeShift function reference: syntax, parameters, and practical examples for parameterizing test plans with dynamic values.

Difficulty
intermediate
Guide type
reference
Estimated read time
1 min read
Last verified version
Verified JMeter 5.6

Also documented in context in the full Functions and Variables reference.

The timeShift function returns a date in the given format with the specified amount of seconds, minutes, hours, days or months added

NameRequiredDescription
FormatNoThe format to be passed to DateTimeFormatter (for input data parsing and output formating). See DateTimeFormatter If omitted, the function uses milliseconds since epoch format.
Date to shiftNoIndicate the date in the format set by the parameter Format to shift. If omitted, the date is set to ZonedDateTime.now with system zone ZoneId.systemDefault(). :::note If Format is empty then this parameter must be long value (look at examples). :::
value to shiftNoIndicate the specified amount of seconds, minutes, hours or days to shift according to a textual representation of a duration such as PnDTnHnMn.nS. See Duration#parse(CharSequence). If ommitted, no shifting will be done. - PT20.345S parses as 20.345 seconds - PT15M parses as 15 minutes - PT10H parses as 10 hours - P2D parses as 2 days - -P6H3M parses as -6 hours and -3 minutes
Locale to use for formatNoThe string format of a locale. The language code must be lowercase. The country code must be uppercase. The separator must be an underscore (_). For example en_EN See supported locales on Java 7. If omitted, by default the function uses the current locale from the JVM.
Name of variableNoThe name of the variable to set.

Examples:

Terminal window
\${__timeShift(dd/MM/yyyy,21/01/2018,P2D,,)}

returns 23/01/2018

Terminal window
\${__timeShift(dd MMMM yyyy,21 fรฉvrier 2018,P2D,fr_FR,)}

returns 23 fรฉvrier 2018

Terminal window
\${__timeShift(,10000,PT10S,,)}

returns 20000 = 10sec input + 10sec shift

Terminal window
\${__timeShift(,,PT10S,,)}

returns 1632158276770 = 1632158266770 ms (now) + 10sec shift

On this page