Need to Change my Date to UTC Format

Aswartha
Mega Contributor

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

 

12 REPLIES 12

Try this once and share the output of date (multiple log statements), if it does not work.

var dueDate1 = new GlideDateTime(current.variables.due_date);
gs.log("Date before setting UTC timezone is "+dueDate1);

var gdt = new GlideDateTime();
var tz = Packages.java.util.TimeZone.getTimeZone("UTC"); //sets to GMT
gdt.setTZ(tz);

gdt.setValue(dueDate1);//this will convert to the UTC.
var date1 = gdt.getDisplayValue();
gs.log("Date after setting UTC timezone is "+date1);

gs.log(date1);
 

Hi Asif,

i am getting this while submitting the form. && IGC format is Like this("2020-02-03T00:00:00Z")

find_real_file.png

Hi,

The message is not related to our code. It seems like you are calling an REST API where you are getting this error.

Check if the date is converted to your UTC format or not by checking the logs output of these lines

gs.log("Date before setting UTC timezone is "+dueDate1);

var gdt = new GlideDateTime();
var tz = Packages.java.util.TimeZone.getTimeZone("UTC"); //sets to GMT
gdt.setTZ(tz);

gdt.setValue(dueDate1);//this will convert to the UTC.
var date1 = gdt.getDisplayValue();
gs.log("Date after setting UTC timezone is "+date1);

Mark the comment as a correct answer and also helpful if it helps.