How to set different timezone with login user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 05:30 AM - edited 12-20-2022 05:58 AM
Hi experts,
I need help from you about timezone.
I want to set time in Work order/ Work order task form.
My timezone (user's timezone) is different with Customer (Account) timezone. I want the time displayed as the customer's timezone.
For example,
my timezone is Asia/Tokyo, the customer's Timezone is Asia/Hong Kong.
I want Set the start Time to 9:00 AM which based on customer's timezone. When I put in the time 9:00 AM in work order/Work order task form, then submit the form.
The time will displayed as 10:00AM for me(time Zone Asia/Tokyou).
How can I implement this?
So far my code is like below, but it just set the time to the timezone of my ServiceNow("Asia/Tokyou"). can you please guide me how to change the timezone?
Thank you.
var startDateTime = new GlideDateTime();
var strsDate = "2022-12-29 9:00:00";
startDateTime.setDisplayValue(strsDate);
startDateTime.setTZ(tz);
var starttimeZoneOffSet = startDateTime.getTZOffset();
starttimeZoneOffSet.setNumericValue(startDateTime.getNumericValue() + starttimeZoneOffSet);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 06:15 AM
Hi Ruchit,
What we have done is the same. We integrate the customer's timezone from sharepoint.
But the time fill in servicenow is not from the form directly. The time set in ServiceNow by code. So I need some timezone convert.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 05:46 AM
Hi @SystemsGo ,
check below links:
Regards,
Reshma
**Please mark my answer correct or helpful based on the impact**
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2023 07:22 PM
Hi All,
Thank you for your reply.
This issue has been resolved. with the following code.
function getDiffwithCustomerTimeZone(dt,strdt){
var zDateTime = new GlideDateTime();
zDateTime.setDisplayValue(strdt);
zDateTime.setTZ(tz);
var timeZoneOffSet = dt.getTZOffset();
var ztimeZoneOffSet = zDateTime.getTZOffset();
var diff = ztimeZoneOffSet-timeZoneOffSet;
dt.setNumericValue(dt.getNumericValue()-diff);
return dt;
}