Highlighted
Valued Contributor.
Valued Contributor.
6112 views

Parameterization of timestamp in timezone different that system timezone

Jump to solution

Hi All,

I am using Loadrunner 12.53. In my recorded script, there is a timestamp (in  Thu, 24 Nov 2016 08:36:55 GMT format) with every request sent to the the server. But my local machine is with IST timezone. 

Is there any way I can paramterize the timestamp so that is sends the request with a GMT timestamp?

The solution i could figure out was to create a date/time timestamp with "%a, %d %b %Y %H:%M:%S" format and replace all occurences with the parameter. But since the parameter reflects system current date/time therefore the request would send a GMT timestamp.

Thanks,

Rachit

Tags (1)
0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Parameterization of timestamp in timezone different that system timezone

Jump to solution

Just small comment... Time offset configuration is avaialble also in Parameters wizard, so you can use "standard" date parameter with the suitable offset (5.5 hours ahead of GMT time -  "Prior to current date" checkbox).

ist_to_gmt.png

View solution in original post

4 Replies
Highlighted
Frequent Contributor.
Frequent Contributor.

Re: Parameterization of timestamp in timezone different that system timezone

Jump to solution

Hello,

lr_save_datetime support a time offset parameter.

Since IST is 5.5 hours ahead of GMT time,  here is a sample code:

lr_save_datetime("Local time(IST) is %a, %d %b %Y %H:%M:%S", DATE_NOW , "IST");
lr_log_message(lr_eval_string("{IST}"));
                   
lr_save_datetime("GMT time is %a, %d %b %Y %H:%M:%S", -(DATE_NOW + ONE_HOUR*5 + ONE_MIN*30), "GMT");                   
lr_log_message(lr_eval_string("{GMT}"));

Regards,

Bingle(LoadRunner R&D)

 

 

Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Parameterization of timestamp in timezone different that system timezone

Jump to solution

Hello,

In case JavaScript engine functionality is convenient for you, there is simple code snippet that returns GMT time instead of local one:

getGMT=function(){ return new Date().toUTCString(); }

Below is the usage sample:

    web_js_run(
        "Code=getGMT=function(){ return new Date().toUTCString(); }",
        LAST);

    web_js_run(
        "Code=getGMT();",
        "ResultParam=gmtTime",
        LAST);

Anyway it looks like reasonable idea to add GMT flag for built-in Date/Time parameters.

Thanks,

Leonid.

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Parameterization of timestamp in timezone different that system timezone

Jump to solution

Just small comment... Time offset configuration is avaialble also in Parameters wizard, so you can use "standard" date parameter with the suitable offset (5.5 hours ahead of GMT time -  "Prior to current date" checkbox).

ist_to_gmt.png

View solution in original post

Highlighted
Valued Contributor.
Valued Contributor.

Re: Parameterization of timestamp in timezone different that system timezone

Jump to solution

Thanks @BingleW and @LeonidPekel. Since I needed to send timestamp with every request, I went ahead with parameterization of the timestamp with offset instead of defining a function and calling it everytime.

 

@LeonidPekel: Even I figured out the offset functionality in the Parameterization wizard post reading your last to last comment and it works out just great.

Was able to sucessfully parameterize the timestamp with offset and its working correctly.

Thanks,

Rachit

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.