How can I change the date format, when I use the API rest to consult a table.

Gustavo13
Mega Contributor

Hi guys, I need to change the date format when I consult a incident using an API

I've already changed the format on the plataform. to dd/mm/yy but when I consult the format is dd-mm-yy.

Result API:   

find_real_file.png

Can you help?

Thanks

Gustavo Petta.

 

1 ACCEPTED SOLUTION

Hi Asifoor

 

I resolved this issue using another parametter on API and configuring the format on instance.

 

Thanks to your help.

View solution in original post

7 REPLIES 7

asifnoor
Kilo Patron

Hello Gustavo,

You can change the format of the date using the below function.

var gd = new GlideDate(); 
var gdt = new GlideDateTime(result[i].sys_created_on).getDate();
gd.setValue(gdt);
gs.info(gd.getByFormat("dd/MM/yyyy"));

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

Hi Asifoor

 

I resolved this issue using another parametter on API and configuring the format on instance.

 

Thanks to your help.

Anik
ServiceNow Employee
ServiceNow Employee

Hi Gustavo, I am facing a similar situation. Planned start date in DD/MM/YYYY format coming in via Rest API is getting set as MM/DD/YYYY thereby showing errors. 

Do you remember how did you make it work? Whats the parameter you are using in your API to convert date-time from US to European format?

 

Thanks,

Anik.