Date time field - set time to 12.00.00

vinitha3
Tera Guru

Hi,

While adding 1 day to the current date, how to set the tiem field alone to 12.00.00?

var gdt = current.sys_created_on;

Trying to add a day here.

Please help me on this.

Thanks,

Vinitha.K

1 ACCEPTED SOLUTION

Shishir Srivast
Mega Sage

Please check if this helps. Sample Script



var dateDueDate = current.sys_created_on;  


var dueDate = new GlideDateTime(dateDueDate);


dueDate.addDaysUTC(1);


var arrDate = [];  


arrDate = dueDate.toString().split(' ');  


current.due_date.setDisplayValue(arrDate[0]+ ' 12:00:00','yyyy-MM-dd HH:mm:ss');



Reference: Set date to specific time


View solution in original post

2 REPLIES 2

Aakash Shah4
Tera Guru

Hello ,



Have you tried to use the adddays() funcation


check here


GlideDateTime - ServiceNow Wiki


Shishir Srivast
Mega Sage

Please check if this helps. Sample Script



var dateDueDate = current.sys_created_on;  


var dueDate = new GlideDateTime(dateDueDate);


dueDate.addDaysUTC(1);


var arrDate = [];  


arrDate = dueDate.toString().split(' ');  


current.due_date.setDisplayValue(arrDate[0]+ ' 12:00:00','yyyy-MM-dd HH:mm:ss');



Reference: Set date to specific time