cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

How we can handle offset in thingworx

Hrishabh.Sharma
11-Garnet

How we can handle offset in thingworx

/**
@Name: Hrishabh Sharma
**/
Hrishab108_0-1720251784391.png

Composer INPUT Offset = result = (new Date()).getTimezoneOffset(); ----Note: Input (offset) shoud be from In Composer (Expression)

 
try {
var startDateSelected;
var endDateSelected;
var StrandName = Strand_Name;
 
if (Offset === undefined || Offset === null || Offset === 0) {
Offset = (new Date()).getTimezoneOffset();
}
var diff1 = (Offset - (new Date()).getTimezoneOffset()) * -1;
var diff2 = (Offset - (new Date()).getTimezoneOffset()) * 1;
if (Start_Date !== undefined) {
startDateSelected = dateAddMinutes(Start_Date, diff1);
}
if (End_Date !== undefined) {
endDateSelected = dateAddMinutes(End_Date, diff1);
}
// result: INFOTABLE dataShape: "CastingStrandParameterLog_DS"
var result1 = Things["Postgresql_TH"].CastingStrandReportForVisualization({
Enddate: endDateSelected /* DATETIME */ ,
Startdate: startDateSelected /* DATETIME */ ,
StrandName: StrandName /* STRING */
});
var sorted_infotable = result1;
var rowSize = sorted_infotable.getRowCount();
me.tes = rowSize;
for (var m; m < rowSize; m++) {
if (diff2 !== 0) {
sorted_infotable.rows[m].timestamp = dateAddMinutes(sorted_infotable.rows[m].timestamp, diff2);
}
}
var result = sorted_infotable;
} catch (e) {
logger.error("Thing: DataServices_TH Services: CastingStrandReportForVisualization ERROR: " + e.message + "Line Number: " + e.lineNumber);
}

ACCEPTED SOLUTION

Accepted Solutions

Hi @Hrishabh.Sharma 

 

(new Date()).getTimezoneOffset() is the only way to get client browser timezone and handle it in Thingworx.

 

/VR

 

View solution in original post

5 REPLIES 5

Hi @Hrishabh.Sharma 

 

Could you please explain your use case

 

/Vr

I'm just asking. Is there any other way to do that things.

if you have any other way or you how to handle that case.

Hi @Hrishabh.Sharma 

 

(new Date()).getTimezoneOffset() is the only way to get client browser timezone and handle it in Thingworx.

 

/VR

 

Hello @Hrishabh.Sharma

 

It looks like you have some responses from a community member. If it helped to answer your question please mark the appropriate reply as the Accepted Solution. 

Of course, if you have more to share on your issue, please let the Community know so other community members can continue to help you.

Thanks,
Vivek N.
Community Moderation Team.

Announcements


Top Tags