Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Setting Variable Date/Time Picker to a default

Manny11
Tera Expert

Hello, 

I am Trying to set a default Date and Time for the Catalog Variable Date Time Picker.

Instance Version: Washington DC

Using Script Include  

 

My script so far is not working, can easily set day 14 days in advance but the time does not seem to set. 

I need to return todays date + 14 days & 5:00 PM . 

 

 

   var gdt = new GlideDateTime();
            gdt.addDays(14);
        var time = new GlideTime();
            time.setValue("17:00:00");
            gdt.setTime(time);
       
       gs.info(gdt.getDisplayValue())
//Expecting to see a time like this:  09/13/2024 05:00 PM
1 ACCEPTED SOLUTION

Brian Lancaster
Kilo Patron

Try this instead.

var gdt = new GlideDateTime();
gdt.addDays(14);
var timeSplit = gdt.toString().split(" ");
var datetime = timeSplit[0] + " 17:00:00";
gs.log(datetime);

View solution in original post

2 REPLIES 2

Brian Lancaster
Kilo Patron

Try this instead.

var gdt = new GlideDateTime();
gdt.addDays(14);
var timeSplit = gdt.toString().split(" ");
var datetime = timeSplit[0] + " 17:00:00";
gs.log(datetime);

Manny11
Tera Expert

Thank you very much for assisting me.