In C#, DateTime.AddSeconds shifts a value by seconds. The parameter is a double, so 0.5 means half a second.
Use it for countdowns, expiry times, and token lifetimes. Large values are fine: 86,400 seconds is exactly one day.
This is an instance member of System.DateTime. You call it on a DateTime value, such as dt.AddSeconds(...). DateTime is a struct, so every value is copied and never changed in place.
Syntax
Pass the number of seconds to add.
C#
DateTime dt = new DateTime(2026, 11, 18, 14, 30, 45);
DateTime a = dt.AddSeconds(30); // 14:31:15
DateTime b = dt.AddSeconds(-46); // 14:29:59
DateTime c = dt.AddSeconds(86400); // next day, same time
Call
What it does
dt.AddSeconds(30)
Thirty seconds later; the minute changes.
dt.AddSeconds(-46)
Forty-six seconds earlier.
dt.AddSeconds(86400)
Exactly one day later.
AddSeconds(3600) equals AddHours(1). All Add methods return a new value and leave the original unchanged.
Library declarations
C#
public DateTime AddSeconds(double value);
Parameters
Parameter
Description
value
Required. Number of seconds to add. Negative values go backward; fractions are allowed.
Return Value
Return Value
Description
DateTime
A new DateTime shifted by value seconds, with the same Kind.
C# Examples
Example 1 — Shift by Seconds
Add 30 seconds and subtract 46 seconds from a fixed time.
C#
using System;
using System.Globalization;
class Program {
static string Show(DateTime d) => d.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
static void Main() {
DateTime dt = new DateTime(2026, 11, 18, 14, 30, 45);
Console.WriteLine(Show(dt.AddSeconds(30)));
Console.WriteLine(Show(dt.AddSeconds(-46)));
}
}
Output
2026-11-18 14:31:15
2026-11-18 14:29:59
How It Works
Plus 30. 14:30:45 plus 30 seconds carries into the next minute, 14:31:15.
Minus 46. 45 seconds minus 46 goes below zero and borrows a minute.
Result 14:29:59. One second before 14:30:00 is the answer.
Carry works both ways. You never fix minutes by hand; the type does it.
Example 2 — 3600 and 86400 Seconds
Show that seconds can express an hour and a whole day.
C#
using System;
using System.Globalization;
class Program {
static string Show(DateTime d) => d.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
static void Main() {
DateTime dt = new DateTime(2026, 11, 18, 14, 30, 45);
Console.WriteLine(dt.AddSeconds(3600) == dt.AddHours(1));
Console.WriteLine(Show(dt.AddSeconds(86400)));
}
}
Output
True
2026-11-19 14:30:45
How It Works
One hour. An hour has 3600 seconds, so both calls land on the same instant.
Equality is by ticks.== compares the exact moment, so it prints True.
One day. 86,400 seconds moves to the same time on November 19.
Pick the readable one. Use AddHours or AddDays when it makes the code clearer.
Example 3 — Fractions of a Second
Add 90 seconds and half a second to midnight.
C#
using System;
using System.Globalization;
class Program {
static void Main() {
DateTime midnight = new DateTime(2026, 11, 18, 0, 0, 0);
DateTime a = midnight.AddSeconds(90);
DateTime b = midnight.AddSeconds(0.5);
Console.WriteLine(a.ToString("HH:mm:ss", CultureInfo.InvariantCulture));
Console.WriteLine(b.ToString("HH:mm:ss.fff", CultureInfo.InvariantCulture));
}
}
Output
00:01:30
00:00:00.500
How It Works
Start at midnight. Every value is easy to read from 00:00:00.
90 seconds. That is one minute and thirty seconds, shown as 00:01:30.
0.5 seconds. A fraction is allowed because the parameter is a double.
fff format. The second line uses .fff so the half second becomes .500.
Frequently Asked Questions
Yes. AddSeconds(0.5) adds half a second.
Yes. Both give the same DateTime.
Use DateTime.UtcNow.AddSeconds(n). Store it as UTC so every server agrees.
No. DateTime ignores leap seconds. Each second is the same length.
No. DateTime is immutable. Use the returned value.