Get the date in HTTP format using _time or _dateTimeConvert function in JMeter

I have the JMeter test where I use the function ${_time()} to get the current time in epoch format.

I know how to convert this date in simple format e.g. ${__dateTimeConvert(${__time},,M/d/yyyy h:mm:ss a)}, but I'm not be able to convert the date in HTTP formats as: "EEE MMM d HH:mm:ss yyyy", "EEE, dd-MMM-yy HH:mm:ss zzz", "EEE, dd MMM yyyy HH:mm:ss zzz" , e.g. Wed, 21 Oct 2020 07:28:00 GMT.

Is it possible for listed functions or I have to use JSR223 sampler with a custom script?

Upvotes: 0

Views: 1570

Answers (2)

Janesh Kodikara
Janesh Kodikara

Reputation: 1841

You can use following letters in the format string for generating custom formats

enter image description here

Few Examples

enter image description here

The format to be passed to SimpleDateFormat.Java API documentation could be useful for generating custom formats.

Upvotes: 2

Ori Marko
Ori Marko

Reputation: 58862

You can use time function with format as

 ${__time(EEE MMM d HH:mm:ss yyyy,)} 

Use __timeShift with only relevant format parameter:

${__timeShift(EEE MMM d HH:mm:ss yyyy)}

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

Upvotes: 2

Related Questions