Glide DateTime

RiteshI
Tera Contributor

How can I add days to my existing date time field

1 REPLY 1

jMarshal
Mega Sage
Mega Sage

I think there's a "addDaysLocalTime()" function oob.

 

// Input date as GlideDateTime object
var inputDate = new GlideDateTime(); // Use current date and time as input
var daysToAdd = 7; // Number of days to add

// Clone the input date to avoid modifying it directly
var newDate = new GlideDateTime(inputDate);

// Add the specified number of days to the new date
newDate.addDaysLocalTime(daysToAdd); // Use addDaysUTC() for UTC time

// Output the new date
gs.info("Input Date: " + inputDate);
gs.info("Number of Days to Add: " + daysToAdd);
gs.info("New Date: " + newDate);