Function Updated 19 Oct 2026
addHours(datetime, hours)
Adding a number of hours (positive or negative value) to a specified date.
Parameters
datetimedatetimerequiredDatetime on which to add hours to.
hoursnumberrequiredHow many hours to add to specified datetime.
Returns
A modified date, does not modify input date.
Example
Mixed HTML (or any text file) with inline JavaScript between hash signs.
#{
var dt = new Date(); // Create new date and time object
write("Before: ");
write(format(dt, "HH:mm")); // output time
dt = docly.addHours(dt, 3.5); // Add 3.5 hours
write(" After: ");
write(format(dt, "HH:mm")); // output time
}#The template above produces this output:
Before: 16:56 After: 20:26