addSeconds() : Add Seconds to Date
On this page
Summary
Add seconds to a datetime. Use negative values to subtract seconds.
Signature
addSeconds(date, seconds)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
date |
DateTime | Yes | The datetime to modify |
seconds |
Number | Yes | Number of seconds to add (can be negative) |
Returns
Type: DateTime
A new DateTime with the specified seconds added.
Examples
Add Seconds
Data:
doc.Params["model"] = new {
startTime = new DateTime(2024, 3, 15, 14, 30, 0)
};
Output:
<p>Timeout: 2:30:30 PM</p>
Countdown Display
Processing Time
Data:
doc.Params["model"] = new {
started = new DateTime(2024, 3, 15, 10, 0, 0),
elapsedSeconds = 125
};
Output:
<p>Completed: 10:02:05</p>
Notes
- Input datetime is not modified (returns new datetime)
- Can add positive or negative seconds
- Automatically handles minute, hour, and day boundaries
- Use
addMilliseconds()for millisecond precision - Use
addMinutes()for minute increments