JMeter Time Functions

JMeter Time Functions


${__time(yyyy-MM-dd-HH:mm:ss:SSS a XXX)} :Generate 2020-10-21-11:16:38:966 AM +05:30

${__timeShift(yyyy-MM-dd HH:mm:ss,,P2D,,)} :Generate a future date by adding 2 days in the current day

${__timeShift(yyyy-MM-dd HH:mm:ss,,PT2H,,)} :Generate a future time by adding 2 hours in the current time

${__timeShift(yyyy-MM-dd HH:mm:ss,,PT2M,,)} :Generate a future time by adding 2 minutes in the current time

${__timeShift(yyyy-MM-dd HH:mm:ss,,P2DT2H,,)} :Generate a future date and time by adding 2 days and 2 hours in the current timestamp

${__timeShift(yyyy-MM-dd HH:mm:ss,,-PT2M,,)} :Generate a past time by reducing 2 minutes in the current time

${__timeShift(yyyy-MM-dd HH:mm:ss,,-P2DT2H,,)} :Generate a past date and time by reducing 2 days and 2 hours in the current timestamp

${__timeShift(yyyy-MM-dd HH:mm:ss,2020-10-20,P2D,,)} :Generate 2020-10-22 which is the next 2nd day from the specified date.


Input Argument:

  1. Format: Refer to the below table for the input format to get the required value.
  2. Name of Variable: To store the generated value in a variable.
FormatExampleDescription
${__time()}1710076012661Current Time in Epoch Format in milliseconds
${__time(/1000)}1710076012Current Time in Epoch Format in seconds
${__time(yyyy)}2024Current Year
${__time(MM)}03Current Month in digit
${__time(MMM)}Mar3 letters of the Current Month
${__time(MMMM)}MarchFull spell of Current Month
${__time(LL)}03Current Month in digit
${__time(LLL)}Mar3 letters of the Current Month
${__time(LLLL)}MarchFull spell of Current Month
${__time(d)} / ${__time(dd)}1 / 01
or
21 / 21
Current Day in one or two digits
${__time(h)} / ${__time(hh)}1 / 01
or
11 / 23
Current Hour in one or two digits in 12-hour format (1-12)
${__time(H)} / ${__time(HH)}1 / 01
or
11 / 23
Current Hour in one or two digits in 24-hour format (0-23)
${__time(k)} / ${__time(kk)}1 / 01
or
11 / 23
Current Hour in one or two digits in 24-hour format (1-24)
${__time(K)} / ${__time(KK)}1 / 01
or
11 / 23
Current Hour in one or two digits in 12-hour format (0-11)
${__time(m)} / ${__time(mm)}5 / 05
or
15 / 15
Current Minute in one or two digits
${__time(s)} / ${__time(ss)}2 / 02
or
19 / 19
Current Second in one or two digits
${__time(S)} / ${__time(SS)} /
${__time(SSS)}
3 / 03 / 003
or
13 / 13 / 013
or
310 / 310 / 310
Current Millisecond in one, two or three digits
${__time(A)}69684021milliseconds
${__time(a)}AM or PMCurrent Meridian
${__time(n)}432000000nano-of-second
${__time(N)}70283500000000nano-of-day
${__time(z)}ISTTimezone in abbreviation
${__time(zzzz)}India Standard TimeTimezone
${__time(Z)}+0530Timezone offset in hours (RFC pattern)
${__time(XXX)}+05:30Timezone offset in ISO format
${__time(O)}GMT+5:30Localized zone-offset
${__time(u)}2024Current Year
${__time(E)} / ${__time(EEEE)}Wed / WednesdayCurrent Day in letters
${__time(e)} / ${__time(c)}1Current Day Number (1 – Sunday, 2 – Monday, 3 – Tuesday, 4 – Wednesday, 5 – Thursday, 6 – Friday, 7 – Saturday)
${__time(ee)} / ${__time(cc)}01Current Day Number (01 – Sunday, 02 – Monday, 03 – Tuesday, 04 – Wednesday, 05 – Thursday, 06 – Friday, 07 – Saturday)
${__time(eee)} / ${__time(ccc)}SunCurrent Day in 3 letters format
${__time(eeee)} / ${__time(cccc)}SundayCurrent Day
${__time(F)}3Week in a month (1 – First week, 2 – Second week)
${__time(D)}70Current day count in the year
${__time(W)}3Week in a month (1 – First week, 2 – Second week)
${__time(w)}11Week in a year
${__time(G)}ADCurrent Era
${__time(Q)}1Quarter of the year in one digit
${__time(QQ)}01Quarter of the year in two digits
${__time(QQQ)}Q1Quarter of the year in alpha-numeric format
${__time(QQQQ)}1st quarterQuarter of the year in alpha-ordinal format

Return Value: the function returns the number, text and symbol which are used for the format. If a variable name is provided as an argument then the return value is stored in that variable.

Example: If you use ${__time(yy-MM-dd-HH:mm:ss:SSS, cTime)} to capture the current timestamp then variable cTime will store the generated value and you can use ${cTime} wherever you want to pass the generated value.

Comments

Popular posts from this blog

LoadRunner Tool

Selenium Performance Testing with JMeter and Selenium Grid

JMeter Integration with AppDynamics