How to add the seconds to the date and time ?

snow57
Tera Contributor

HI,

 

I am running the below code in the background script , but resulting as undefined. Could someone please help me to resolve this .

var d1 = '2023-09-22 21:13:58';
var d2 = '2023-09-22 21:43:58';
var d3 = '2023-09-23 21:43:58';
var dr ;
dr = gs.dateDiff(d1,d2,true);
d3.addSeconds(dr);
gs.print('dr' + d3.getValue());
 
Thanks,
 
5 REPLIES 5

Pavankumar_1
Mega Patron

Hi @snow57 ,

If my response helps you to resolve the issue Accept the solution and close it. So that others can refer and get benefited.

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar