how to convert the date time to the format yyyy-MM-ddTHH:mm:ss ±hh:mm

thilagavathysar
Mega Expert

Hi All,

I have a requirement to send date time values in specific format in SOAP request. I want to convert the date time field value to the format yyyy-MM-ddTHH:mm:ss ±hh:mm. Please help with your suggestions. Thanks in advance!

 

Regards,

Thilagavathy S

 

3 REPLIES 3

Rahul RJ
Giga Sage
Giga Sage

Hi,

You can this link

 

Thanks,

RJ

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you will have to convert your date/time to ISO format

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

You can use this line of code to convert the time to ISO format

var myDate = new Date();
var isoDateTime = myDate.toISOString();
gs.info(isoDateTime);

Output:

[0:00:00.038] Script completed in scope global: script


Script execution history and recovery available here


*** Script: 2021-01-07T13:43:38.090Z

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader