addSeconds(datetime, seconds) Last updated: 01. May 2026

Adding a number of seconds (positive or negative value) to a specified date and time.

See also: Compare date field with todays date Get todays date SetCulture date og number format

Parameters

Name Type Description
datetime Datetime object Date and time on which to add seconds to.
seconds number (int or float) How many seconds 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 before = new Date(); // Create new date and time object
    var after = docly.addSeconds(before, 33); // Add seconds
}#
<b>Before:</b> #format(before, "HH:mm:ss")#
<b>After:</b> #format(after, "HH:mm:ss")#

Output

The #JS code above produces the output shown below:
<b>Before:</b> 14:48:53
<b>After:</b> 14:49:26