Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

how to convert the date format

hemanth40
Tera Contributor
"hireDate": "/Date(1682726400000)/",
 
how can i convert this to date format?
1 ACCEPTED SOLUTION

example script:

var dateStr = "/Date(1682726400000)/";

var intDate = dateStr.substring(dateStr.indexOf("(")+1, dateStr.indexOf(")"));

var gdtTesting = new GlideDateTime();
gdtTesting.setNumericValue(intDate);
gs.log(gdtTesting);

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

View solution in original post

5 REPLIES 5

Pratiksha
Mega Sage
Mega Sage

From where you are getting the data?

i get this one in a JSON formate

 

JSON /Date()/

Ahmmed Ali
Giga Sage
Giga Sage

Hello @hemanth40 

 

you can get integer value and use setNumebrValue() function in GlideDateTime to get display value.

example script:

 

var gdtTesting = new GlideDateTime();
gdtTesting.setNumericValue(1682726400000);
gs.log(gdtTesting);

 

Thank you,

Ali

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali

example script:

var dateStr = "/Date(1682726400000)/";

var intDate = dateStr.substring(dateStr.indexOf("(")+1, dateStr.indexOf(")"));

var gdtTesting = new GlideDateTime();
gdtTesting.setNumericValue(intDate);
gs.log(gdtTesting);

 

 

If I could help you with your Query then, please hit the Thumb Icon and mark my answer as Correct!!

Thank you,
Ali