Add 30 minutes to the date using newDateTime() possible?

E_19
Giga Expert

Hi All,

I have a client script that processes and create a new change with many field completed.

I also need to add start and end date on certain conditions.

Start date is no problem using gs.nowDateTime();

grCH.start_date = gs.nowDateTime();

For the end date, all I need to do is add 30 min to the date/time that is set in start_date but I cannot figure out how to do this.

grCH.end_date ??

Any suggestions greatly welcome.

Thanks,

Ellie

1 ACCEPTED SOLUTION

Mike Allen
Mega Sage

This is how we do it in a Default value of the field:



javascript: getDateTime();



function getDateTime() {


var dateTime = new GlideDateTime();


dateTime.addSeconds(1800);


return dateTime.getDisplayValue();


}


View solution in original post

4 REPLIES 4

Mike Allen
Mega Sage

This is how we do it in a Default value of the field:



javascript: getDateTime();



function getDateTime() {


var dateTime = new GlideDateTime();


dateTime.addSeconds(1800);


return dateTime.getDisplayValue();


}


Thanks Mike,


I have been able to convert it and use in my script include.


Regards,


Ellie


fredflintstone
Kilo Expert

Will be in GMT, but this is one approach:



gs.minutesAgo(-30)



Check out the GlideSystem API documentation: https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=c_GlideSystemAPI


Sachin52
Tera Contributor

javascript:var DT = new GlideDateTime(); DT.addSeconds(1800); DT.getDisplayValue();

 

Hit like if helpful