Skip to main content
Jul 6, 2024 7:46 AM UTC
Solved

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);
}

VelkumarAnswer
Jul 9, 2024 5:21 AM UTC

Hi @Hrishabh.Sharma 

 

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

 

/VR

 

5 replies

Jul 8, 2024 5:21 AM UTC

Hi @Hrishabh.Sharma 

 

Could you please explain your use case

 

/Vr

Jul 8, 2024 3:53 PM UTC

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

Jul 8, 2024 3:54 PM UTC

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

Jul 12, 2024 7:48 AM UTC

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.