Need to Change my Date to UTC Format
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2020 10:47 PM
Hi Everyone,
I am integrating Servicenow to IGC(Which is 3rd party Application) through Servicenow Workflow.
i am able to pass all the field values into IGC,but due_date value is not passing to IGC(showing error:Unable to parse the Date Format)
Date format in IGC is UTC, so in Run script how can i changes my Date format to UTC.
If anyone knows, please let me know, i need to submit this task ASAP
Thank you,
Aswartha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2020 10:55 PM
Hi
Try adding this into the code before you pass it -
var temp = new Packages.java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss");// the format that you want to send.
var ddt;
ddt = temp.parse();
and pass this ddt to your setStringParameter.
Regards
Omkar Mone

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2020 11:26 PM
Hi Awartha,
You can convert the date to another timezone like this.
var gdt = new GlideDateTime();
var tz = Packages.java.util.TimeZone.getTimeZone("GMT"); //sets to GMT
gdt.setTZ(tz);
gdt.setValue(your_date);//this will convert to the GMT.
gs.print(gdt.getDisplayValue());
Mark the comment as a correct answer and also helpful if it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2020 01:15 AM
Hi Asif, Thank you very much for Responding...
var dueDate1 = current.variables.due_date;
var gdt = new GlideDateTime();
var tz = Packages.java.util.TimeZone.getTimeZone("UTC"); //sets to GMT
gdt.setTZ(tz);
var date1 = gdt.setValue(dueDate1);//this will convert to the GMT.
//gs.print(gdt.getDisplayValue());
try {
var r = new sn_ws.RESTMessageV2('Creating Terms in IGC with Snow workflo', 'Post Terms');
r.setStringParameterNoEscape('custom_Due date',date1 );
I tried with your code but its not Working, can you please help me to fix this
Thank you
Aswartha

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2020 03:19 AM
Try like this. If it does not work, share the output of the log statements that i have added in this code.
var dueDate1 = new GlideDateTime(current.variables.due_date);
var gdt = new GlideDateTime();
var tz = Packages.java.util.TimeZone.getTimeZone("UTC"); //sets to GMT
gdt.setTZ(tz);
var date1 = gdt.setValue(dueDate1);//this will convert to the GMT.
//gs.print(gdt.getDisplayValue());
gs.log(date1);
var tz = gs.getSession().getTimeZone();
gs.log (" system time zone is "+tz);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-03-2020 03:46 AM
Mark the comment as a correct answer and also helpful if it helps.