• Jmeter 常用函数(32)- 详解 __timeShift


    如果你想查看更多 Jmeter 常用函数可以在这篇文章找找哦

    https://www.cnblogs.com/poloyy/p/13291704.html

    作用

    以给定格式返回日期,并添加指定的秒数,分钟,小时,天数

    语法格式

    ${__timeShift(Format, Date to Shift, Value to Shift, Locale to use for format, Name of variable)}

    参数讲解

    字段含义是否必传
    Format
    • DateTimeFormatter,日期格式
    • 不指定默认会返回毫秒数。建议格式: yyyy/MM/dd HH:mm:ss 
    no
    Date to shift 要转换的日期。如果省略,则日期设置为现在 no
    Value to shift 要移动的时间数 no
    Locale to use for format 语言环境的字符串格式,如:zh_CN、en_US no
    Name of variable 存储结果的变量名 no

    Value to shift 

    重点讲下这个参数,它主要是表示要移动的秒、分、小时、天、月的数量,具体栗子如下

        "PT20.345S" -- 增加 20.345"PT15M"     -- 增加 15 分钟
        "PT10H"     -- 增加 10 消失
        "P2D"       -- 增加 2"P2DT3H4M"  -- 增加 23 小时 4 分钟
        "PT-6H3M"    -- 减少 6 小时,同时增加 3 分钟
        "-PT6H3M"    -- 减少 6小时 3 分钟
        "-PT-6H+3M"  -- 增加 6 小时,同时减少 3 分钟
    • 如果是增减时、分、秒,前缀是 PT 
    • 如果是增减天,前缀是  P 

    小栗子

    增加 20.345 秒

    ${__timeShift(yyyy/MM/dd HH:mm:ss, 2020/12/05 13:39:16, PT20.345S,,)}
    • 当前时间:2020/12/05 13:39:16
    • 返回结果:2020/12/05 13:39:36

    增加 10 分钟、21 秒

    ${__timeShift(yyyy/MM/dd HH:mm:ss,2020/12/05 13:39:16,PT10m21s,,)}
    • 当前时间:2020/12/05 13:39:16
    • 返回结果:2020/12/05 13:49:37

    减少 2 小时,增加 20 分钟、11 秒

    ${__timeShift(yyyy/MM/dd HH:mm:ss,2020/12/05 13:39:16,PT-2h20m11s,,)}
    • 当前时间:2020/12/05 13:39:16
    • 返回结果:2020/12/05 11:59:27

    减少 2 小时、2 分钟、2 秒

    ${__timeShift(yyyy/MM/dd HH:mm:ss,2020/12/05 13:39:16,-PT2h2m2s,,)}
    • 当前时间:2020/12/05 13:39:16
    • 返回结果:2020/12/05 11:37:14

    增加 2 天数、3 小时、4 秒

    ${__timeShift(yyyy/MM/dd HH:mm:ss,2020/12/05 13:39:16,P2DT3H4S,,)}
    • 当前时间:2020/12/05 13:39:16
    • 返回结果:2020/12/07 16:39:20

     

    减少 2 天数,增加 2 小时、4 分钟,减少 2 s

    ${__timeShift(yyyy/MM/dd HH:mm:ss,2020/12/05 13:39:16,P-2DT+2h4m-2s,,)}
    • 当前时间:2020/12/05 13:39:16
    • 返回结果:2020/12/03 15:43:14

  • 相关阅读:
    【线程退出】linux线程退出的几个函数
    Apache Doris编译安装记录
    你所不知道的java编程思想
    thinking in java知识小记(一)
    一个程序员的修炼之路
    解决linux不能使用chmod更改权限的问题
    centos6.5配置无线网络
    ubuntu16.04 server安装小记
    vim的基本使用方法
    微信之父张小龙经典演讲164页PPT:《微信背后的产品观》
  • 原文地址:https://www.cnblogs.com/poloyy/p/14089273.html
Copyright © 2020-2023  润新知