I am using JMeter for regression testing, and needed a way to use the current (today’s) date in mm/dd/yyyy format in a form post. Here is the solution I came up with using the JavaScript function:

${__javaScript(d = new Date; prefix=d.getMonth()<9?'0':'';X = prefix + String(d.getMonth()+1) + '/' + d.getDate() + '/' + d.getFullYear(), Dummy)}

Looks like date formatting in JavaScript is a perpetual problem, so I hope this is helpful.

Leave a Reply

You must be logged in to post a comment.