Fix script does not update record correctly

dev_K
Tera Contributor

Hi All,

 

I have a script that fixes a value on a record

 

if (gr.next()) {
  gr.setValue('due_date', '15/01/2026 00:00:00');
  gr.update();
  
 
it works but not for the hour, the hour is always updated to 01:00:00:
dev_K_0-1743154241678.png

 

how can I set it to 00:00:00??

5 REPLIES 5

Nilesh Pol
Kilo Sage

@dev_K 

You can modify your script to use GlideDateTime and set the time explicitly to 00:00:00. Here's how you can do it:

var gr = new GlideRecord('your_table_name'); 
if (gr.next()) {
var gdt = new GlideDateTime('2026-01-15 00:00:00'); 
gr.setValue('due_date', gdt); 
gr.update();
}

@dev_K 

Ankur Bawiskar
Tera Patron

@dev_K 

it's date/time so whatever value you set it will display as per logged in user's timezone

did you check value in XML is 00:00:00?

Seems your timezone is having 1 hour difference with GMT and hence it's showing as 1 hour ahead.

If my response helped please mark it correct and close the thread so that it benefits future readers.

@dev_K 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.