简体   繁体   中英

__timeShift function not returning the previous year date

I'm using the __timeShift function as follows

${__timeShift(YYYY-MM-dd hh:mm,,-P7D,,)}

My current date is 3rd of January 2023. I'm expecting 2022-12-27 02:13 but getting output as 2023-12-27 02:13 .

If my current date is 10th of January 2023, then I should get output as 2023-01-03 02:13. So I should be able to get the date 7 days previous to current date.

I'm not sure how to give the formatting and options in __timeShift function to have proper date. Please do help me in this.

Here is what I have tried... Link to Img

${__timeShift(YYYY-MM-dd hh:mm,,-7D,,)}

This will shift the current date backwards by 7 days, and the output will be in the format YYYY-MM-dd hh:mm, as specified by the first parameter.

If you want to include the time in the output, you can specify the current time using the __time function, like this:

${__timeShift(YYYY-MM-dd hh:mm,${__time(hh:mm)},-7D,,)}

I cannot reproduce your issue using latest stable JMeter 5.5 and the following__timeShift() function syntax:

${__timeShift(YYYY-MM-dd hh:mm,,-P7D,,)}

在此处输入图像描述

so double check your operating system date and ensure you're using the latest stable JMeter version which is available at JMeter Downloads page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM