In C#, DateTime.AddHours shifts a value by a number of hours. The argument is a double, so 0.5 means thirty minutes and -3 means three hours earlier.
If the hours cross midnight, the date part changes too. The method does not know about time zones, so it is plain clock arithmetic.
This is an instance member of System.DateTime. You call it on a DateTime value, such as dt.AddHours(...). DateTime is a struct, so every value is copied and never changed in place.
Syntax
Pass a number of hours to AddHours.
C#
DateTime dt = new DateTime(2026, 11, 18, 14, 30, 45);
DateTime a = dt.AddHours(3); // 17:30:45
DateTime b = dt.AddHours(-15); // previous day 23:30:45
DateTime c = dt.AddHours(0.5); // 15:00:45
Call
What it does
dt.AddHours(3)
Three hours later.
dt.AddHours(-15)
Fifteen hours earlier, which crosses midnight.
dt.AddHours(0.5)
Half an hour later.
AddHours(2) gives the same result as Add(TimeSpan.FromHours(2)). Use ToUniversalTime or TimeZoneInfo when real time zone rules matter.
Library declarations
C#
public DateTime AddHours(double value);
Parameters
Parameter
Description
value
Required. Number of hours to add. Negative values go backward; fractions are allowed.
Return Value
Return Value
Description
DateTime
A new DateTime shifted by value hours, with the same Kind.
C# Examples
Example 1 — Shift by Whole Hours
Add three hours, then subtract fifteen hours across midnight.
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.AddHours(3)));
Console.WriteLine(Show(dt.AddHours(-15)));
}
}
Output
2026-11-18 17:30:45
2026-11-17 23:30:45
How It Works
Three hours on. 14:30:45 becomes 17:30:45 on the same day.
Fifteen hours back. 14:30:45 minus 15 hours is half an hour before midnight.
Date changes. The second result belongs to November 17 because the clock crossed midnight.
Minutes and seconds. They stay 30 and 45 because only whole hours moved.
Example 2 — Fractions and Long Shifts
Add half an hour and then more than a full day of hours.
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.AddHours(0.5)));
Console.WriteLine(Show(dt.AddHours(25)));
}
}
Output
2026-11-18 15:00:45
2026-11-19 15:30:45
How It Works
0.5 hours. Thirty minutes later moves 14:30:45 to 15:00:45.
25 hours. One full day plus one hour gives the next day at 15:30:45.
No limit at 24. You can pass any size; the date rolls over as many times as needed.
Still new values. Both lines come from fresh DateTime results; dt itself is the same.
Example 3 — Shift a UTC Time
Add 5.5 hours to a UTC time and compare AddHours with Add.
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 utc = new DateTime(2026, 11, 18, 9, 0, 0, DateTimeKind.Utc);
DateTime ist = utc.AddHours(5.5);
Console.WriteLine(Show(ist));
Console.WriteLine(utc.AddHours(2) == utc.Add(TimeSpan.FromHours(2)));
}
}
Output
2026-11-18 14:30:00
True
How It Works
UTC start. The value is 09:00 with Kind set to Utc.
Plus 5.5 hours. India Standard Time is UTC+05:30, so the clock shows 14:30.
Simple arithmetic. The result keeps Kind.Utc; it is only a shifted number, not a real zone conversion.
Same as Add.AddHours(2) equals Add(TimeSpan.FromHours(2)), so the check prints True.
Frequently Asked Questions
Yes. AddHours(0.5) adds thirty minutes and AddHours(1.25) adds one hour fifteen minutes.
Yes, when the hours cross midnight the date part moves forward or back.
Yes. They produce the same value. AddHours is just shorter.
No. It adds exact hours to the clock value. Use TimeZoneInfo for time zone rules.
No. DateTime is immutable, so you must use the returned value.