简体   繁体   English

__timeShift function 不返回上一年的日期

[英]__timeShift function not returning the previous year date

I'm using the __timeShift function as follows我使用 __timeShift function 如下

${__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 .当前的日期是 2023 年 1 月 3 日。期待 2022-12-27 02:13得到 output 作为 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.如果我当前的日期是 2023 年 1 月 10 日,那么我应该得到 output 作为 2023-01-03 02:13。 So I should be able to get the date 7 days previous to current date.所以我应该能够得到当前日期前 7 天的日期。

I'm not sure how to give the formatting and options in __timeShift function to have proper date.我不确定如何在 __timeShift function 中提供格式和选项以获得正确的日期。 Please do help me in this.请在这方面帮助我。

Here is what I have tried... Link to Img这是我尝试过的...链接到 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.这会将当前日期向后移动 7 天,并且 output 将采用第一个参数指定的 YYYY-MM-dd hh:mm 格式。

If you want to include the time in the output, you can specify the current time using the __time function, like this:如果要在 output 中包含时间,可以使用 __time function 指定当前时间,如下所示:

${__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:我无法使用最新的稳定版 JMeter 5.5和以下__timeShift() function 语法重现您的问题:

${__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.因此,请仔细检查您的操作系统日期并确保您使用的是最新的稳定版本 JMeter,该版本可在JMeter 下载页面获得。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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