how convert current user time zone date/time into UTC
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-02-2024 10:15 AM
Hi all
currently we are using soap outbound integration when were we are send date/time fields payload it should be convert into UTC time zone
Thanks in advance
Sree
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-02-2024 11:01 AM
Hi @sree06
Please check this-
var userDateTime = new GlideDateTime();
var userTimeZone = gs.getSession().getTimeZoneName();
gs.info("User's Date/Time (Local): " + userDateTime.getDisplayValue());
userDateTime.setTZ(userTimeZone);
var utcDateTime = userDateTime.getDisplayValue(); // This will be in UTC
gs.info("UTC Date/Time: " + utcDateTime);
Please mark my answer helpful and correct.
Regards,
Amit
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā04-02-2024 12:56 PM
Hi @sree06,
Since ServiceNow stores date/time in UTC by default, there shouldn't be a need to convert it.
Use something like:
var someGDT = new GlideDateTime( current.getValue('date_time_field'));