How do I script a GlideDate and GlideDateTime

asher14
Tera Contributor

I am parsing a JSON. When a change request is submitted I want to auto populate the planned start date and planned end date. The start date show be the current users local time and the end date should be 5 minutes from the start date. How do I script the start date and end date ? I know the glidedate & glidedatetime format but it is not showing up when I open the newly submitted change request. 

//gdt get date/time
vargdt=newGlideDateTime();
vargd=newGlideDate();
vardate=gd.getByFormat("MM-dd-yyyy");
gd.setValue(gdt.localTime);
varhour=gd.getByFormat("HH:mm");

 

find_real_file.png

2 REPLIES 2

Aman Kumar S
Kilo Patron

Configure dictionary of Planned start date and set default value as

 javascript: new GlideDateTime();

And for planned end date as:

javascript: var y = new GlideDateTime(x); y.addSeconds(300); y;

Best Regards
Aman Kumar

heres what I have so far:

//gdt get date/time
var gdt=newGlideDateTime();
var gd=newGlideDate();
var date=gd.getByFormat("MM-dd-yyyy");
gd.setValue(gdt.localTime);
var hour=gd.getByFormat("HH:mm");