
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-10-2020 08:37 AM
I am using the below code in business rule to get the change start date and split the date and time values and insert into custom table.
While inserting the record in custom table, the value has to be in eastern time zone. Since the date and time are string field in custom table, I am facing difficulties when the user is in different time zone.
Example: If the user is in Central time zone, the display value of the date is copied into target field. However before copying it has to be converted to Eastern time zone irrespective of user time zone.
Can anyone help me on this?
if(current.start_date.getDisplayValue()!=""){
var date_time = current.start_date.getDisplayValue();
var date_split = date_time.split(" ")[0];
var time_split = date_time.split(" ")[1];
var month = date_split.split("-")[0];
var day = date_split.split("-")[1];
var year = date_split.split("-")[2];
var hours = time_split.split(":")[0];
var minutes = time_split.split(":")[1];
var seconds = time_split.split(":")[2];
newdate = date_split;
newtime = hours + ":" + minutes;
}
target.u_change_start_date = newdate;
target.u_start_time = newtime;
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-11-2020 06:58 AM
refer sample script to get the time in Eastern timezone
Remember this would work only in global scope and not custom scope as it uses Packages call
var time = new GlideDateTime();
gs.info('GMT time is->'+time);
var tz = Packages.java.util.TimeZone.getTimeZone('US/Eastern');
time.setTZ(tz);
var timeZoneOffSet = time.getTZOffset();
time.setNumericValue(time.getNumericValue() + timeZoneOffSet);
gs.info('Eastern time is->'+time);
Output:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 01:45 AM
Hi
I have issue here I am using this for scoped qualys application, java methods are not working there, so is there any other way?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2022 02:30 AM
Can you post a separate question and tag me there as this is quite older thread?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2022 06:09 AM
how to convert time from US timezone to indian time zone?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2022 06:19 AM
There are some simple OOB functions available to change the timezone. Please go to the below link.
Regards,
Nayan

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-04-2022 06:18 AM
There are some simple OOB functions available to change the timezone. Please go to the below link.
Regards,
Nayan