How to convert Microsoft JSON Date(1641618000000) to ServiceNow format(2022-08-31)

GD11
Tera Expert

I am getting date field values from 3rd party App through REST call in Microsoft Date format as shown below and I want to convert it into YYYY-MM-DD or any other servicenow format.

 

renewdate: 1641618000000

@asifnoor @Chandu12 @Ankur Bawiskar 

1 ACCEPTED SOLUTION

Tony Chatfield1
Kilo Patron

Hi, it looks like this is not Microsoft specific and just the time in milliseconds IE Unix\epoc time since 1970-01-01 00:00:00 (creation date for the universe).

Unix Time Stamp - Epoch Converter

 

GlideDateTime() has the setNumericValue() for managing the conversion.

GlideDateTime | ServiceNow Developers

 

var renewdate = '1641618000000';
var gdt = new GlideDateTime();

gdt.setNumericValue(renewdate);

gs.info(gdt);

View solution in original post

1 REPLY 1

Tony Chatfield1
Kilo Patron

Hi, it looks like this is not Microsoft specific and just the time in milliseconds IE Unix\epoc time since 1970-01-01 00:00:00 (creation date for the universe).

Unix Time Stamp - Epoch Converter

 

GlideDateTime() has the setNumericValue() for managing the conversion.

GlideDateTime | ServiceNow Developers

 

var renewdate = '1641618000000';
var gdt = new GlideDateTime();

gdt.setNumericValue(renewdate);

gs.info(gdt);