Docly Developers
Function Updated 19 Oct 2026

addHours(datetime, hours)

Adding a number of hours (positive or negative value) to a specified date.

Parameters

datetimedatetimerequired

Datetime on which to add hours to.

hoursnumberrequired

How 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
}#