We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Not able to convert timezone of selected date and time in scoped app

TanviP003244604
Tera Contributor

Hi Everyone,

 

I'm working in a scoped application and facing an issue with time zone conversion.

 

I have two Date/Time fields:

 

Scheduled Date Time (user input)

CDT Date Time (target field)

 

Requirement:

 

When a user selects a value in the Scheduled Date Time field, I need to check the logged-in user's time zone.

If the user's time zone is one of the following:

US Central

US Pacific

US Mountain

IDT

Then I need to convert the selected Scheduled Date Time value to CDT (Central Daylight Time) and populate the second Date/Time field.

 

I'm trying to implement this using a client-callable Script Include and GlideDateTime APIs and client script. However, since this is a scoped application, methods such as setTZ() are not supported.

 

Has anyone implemented a similar requirement in a scoped app? What would be the recommended approach for converting a Date/Time value from the user's time zone to CDT and returning the converted value to the client?

 

Any guidance would be greatly appreciated.

1 REPLY 1

Sara Moushier
Tera Contributor

Hello,

Try to use GlideScheduleDateTime should work in scopped applications

var gsdt = new GlideScheduleDateTime(technical_name_of_the_field);
gsdt.setTimeZone("New Timezone");