The cleanest way to add seconds to a date in TypeScript is to read the timestamp with getTime(), add the seconds times 1000, and wrap the sum in a new Date. Your original date isn’t touched:
const later = new Date(date.getTime() + seconds * 1000);
I ran every snippet here with TypeScript 7.0.2 and Node.js v22.22.2 in strict mode, so the printed results are real.
In this tutorial, we’ll build a typed helper, try setSeconds() and its rollover, check a daylight saving change, and work out token expiry times.
Add seconds to a date with getTime()
A Date is just a count of milliseconds since 1970 (the Unix epoch). So multiplying by 1000 works, and negative seconds go backward:
function addSeconds(date: Date, seconds: number): Date {
return new Date(date.getTime() + seconds * 1000);
}
const start = new Date("2026-11-26T09:15:00Z");
const later = addSeconds(start, 45);
const back = addSeconds(start, -90);
console.log("start: ", start.toISOString());
console.log("+45 s: ", later.toISOString());
console.log("-90 s: ", back.toISOString());
console.log("unchanged:", start.toISOString());
Output:
start: 2026-11-26T09:15:00.000Z
+45 s: 2026-11-26T09:15:45.000Z
-90 s: 2026-11-26T09:13:30.000Z
unchanged: 2026-11-26T09:15:00.000Z

Need a raw millisecond value instead of a Date? I cover that in getting the current date in milliseconds.
Add seconds with setSeconds() and handle rollover
setSeconds() and setUTCSeconds() accept values past 59 and carry the extra into minutes, hours and days. They edit the object in place, so copy it first:
const meeting = new Date("2026-11-26T09:59:30Z");
const copy = new Date(meeting); // copy first
copy.setUTCSeconds(copy.getUTCSeconds() + 90);
console.log("original:", meeting.toISOString());
console.log("+90 s: ", copy.toISOString());
const endOfYear = new Date("2026-12-31T23:59:50Z");
endOfYear.setUTCSeconds(endOfYear.getUTCSeconds() + 15);
console.log("rollover:", endOfYear.toISOString());
const shared = new Date("2026-11-26T09:00:00Z");
const alias = shared; // same object, not a copy
alias.setUTCSeconds(30);
console.log("shared changed too:", shared.toISOString());
Output:
original: 2026-11-26T09:59:30.000Z
+90 s: 2026-11-26T10:01:00.000Z
rollover: 2027-01-01T00:00:05.000Z
shared changed too: 2026-11-26T09:00:30.000Z

The last line is the classic bug: const alias = shared doesn’t copy anything. For bigger steps, the same pattern appears in adding minutes to a date in TypeScript and adding days to a date.
Does adding seconds work across a daylight saving change?
Yes, with getTime(). It adds real elapsed time, so the wall clock can repeat an hour when US clocks fall back on November 1, 2026:
function addSeconds(date: Date, seconds: number): Date {
return new Date(date.getTime() + seconds * 1000);
}
const fmt = (d: Date) =>
d.toLocaleString("en-US", { timeZone: "America/New_York", timeZoneName: "short" });
// 1:30 AM EDT on Sunday, November 1, 2026 (US clocks fall back at 2:00 AM)
const beforeChange = new Date("2026-11-01T05:30:00Z");
console.log("start: ", fmt(beforeChange));
console.log("+3600 seconds:", fmt(addSeconds(beforeChange, 3600)));
console.log("+7200 seconds:", fmt(addSeconds(beforeChange, 7200)));
Output:
start: 11/1/2026, 1:30:00 AM EDT
+3600 seconds: 11/1/2026, 1:30:00 AM EST
+7200 seconds: 11/1/2026, 2:30:00 AM EST

That’s correct for timers and timeouts. To show results in a user’s zone, see formatting a date with a time zone in TypeScript.
Add seconds to a Unix timestamp or token expiry
APIs often send durations in seconds, like an OAuth expires_in. Unix timestamps in seconds also need converting before they meet a Date:
interface TokenResponse {
access_token: string;
expires_in: number; // seconds, as most OAuth servers send it
}
const issuedAt = new Date("2026-11-26T14:00:00Z");
const res: TokenResponse = { access_token: "demo", expires_in: 3599 };
const expiresAt = new Date(issuedAt.getTime() + res.expires_in * 1000);
console.log("expires at:", expiresAt.toISOString());
const unixSeconds = Math.floor(issuedAt.getTime() / 1000);
console.log("unix seconds now:", unixSeconds, "-> +300:", unixSeconds + 300);
console.log("back to Date:", new Date((unixSeconds + 300) * 1000).toISOString());
Output:
expires at: 2026-11-26T14:59:59.000Z
unix seconds now: 1795701600 -> +300: 1795701900
back to Date: 2026-11-26T14:05:00.000Z
Going the other way, subtract two dates and divide by 1000 for seconds; for whole days use the date difference in days.
Why won’t TypeScript let me pass a string of seconds?
Values from query strings, forms or JSON often arrive as text. With a number parameter, strict mode stops the bug at compile time:
function addSeconds(date: Date, seconds: number): Date {
return new Date(date.getTime() + seconds * 1000);
}
const fromQuery = "30"; // e.g. ?delay=30
addSeconds(new Date(), fromQuery);
Output:
string_seconds.ts(6,24): error TS2345: Argument of type 'string' is not assignable to parameter of type 'number'.

Convert with Number() and confirm the result is finite. Then check the date itself, as in checking for invalid dates in TypeScript.
Ways to add seconds in TypeScript compared
| Approach | Changes original? | Best for |
|---|---|---|
new Date(d.getTime() + s * 1000) | No | Most code, exact elapsed time |
setSeconds(getSeconds() + s) | Yes | Local wall-clock edits on a copy |
Unix seconds + s | No | APIs and JWT timestamps |
More date guides you can try next:
- Subtract days from a date in TypeScript
- Compare dates in TypeScript
- Convert dates to UTC in TypeScript
- Format dates in TypeScript
Frequently asked questions
How do I add seconds to a date in TypeScript?
Use new Date(date.getTime() + seconds * 1000). It returns a new date and leaves the original alone.
How do I subtract seconds from a date?
Pass a negative number, like addSeconds(date, -90), or subtract seconds * 1000 from getTime().
What happens if I add more than 59 seconds with setSeconds()?
The extra rolls into the next minute, hour or day automatically.
Why did my original date change?
setSeconds() edits the object in place, and assigning a date to another variable shares it. Copy with new Date(date) first.
Should I use date-fns addSeconds instead?
It returns a new date the same way. Use it if date-fns is already in your project.
Where is the JavaScript Date object documented?
See Date.prototype.setSeconds() on MDN.

Bijay Kumar is a 13-time Microsoft MVP with more than 18 years in software development, and the founder of Python Guides and TSinfo Technologies. He started out building .NET and SharePoint solutions at HP, TCS and KPIT before moving into Python, machine learning and AI, and he also builds web apps with TypeScript and React. He writes the tutorials here himself, and every example is run before publishing so you see the real output. More about Bijay · Microsoft MVP profile · LinkedIn