AddHours(datetime, hours) Last updated: 21. Dec 2022
Adding a number of days (positive or negative value) to a specified date.
Parameters
Name | Type | Description |
---|---|---|
datetime | Datetime object | Date on which to add days to. |
hours | number (int or float) | How many hours to add to specified datetime. |
Returns
A modified date, does not modify input date.
Example
Code example (#JS)
#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.#{
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
}#
Output
The #JS code above produces the output shown below:Before: 10:54 After: 14:24