Skip to main content

How to Add Minutes to the Current UTC Time in C#

· 4 min read
Jagdish Kumawat
Founder @ Dewiride

"Fifteen minutes from now" is a common need: an expiry time, a reminder, a timeout. In C#, DateTime.UtcNow gives the current time in UTC and AddMinutes(15) gives the time a quarter of an hour later, as a new value.

Syntax​

Syntax
DateTime <now> = DateTime.UtcNow;
DateTime <later> = <now>.AddMinutes(<minutes>);
PartWhat it does
DateTime.UtcNowThe current date and time in UTC.
.AddMinutes(<minutes>)Returns a new DateTime that many minutes later. A negative number goes back in time.
<later>The new value. The original <now> doesn't change.

The .NET API documentation for AddMinutes: "Returns a new DateTime that adds the specified number of minutes to the value of this instance." Its remarks add: "This method does not change the value of this DateTime. Instead, it returns a new DateTime whose value is the result of this operation."

The Example​

The example takes the current UTC time, works out the time 15 minutes later, and prints both times and the gap between them.

Prerequisites​

  • The .NET 10 SDK or newer, which runs a single .cs file with dotnet run. This guide uses .NET SDK 10.0.404.

Step 1: Write the Code​

Create a file named main.cs in an empty folder:

main.cs, which sets now to DateTime.UtcNow and expires to now.AddMinutes(15), prints both with the u format and prints expires minus now.

main.cs
var now = DateTime.UtcNow;
var expires = now.AddMinutes(15);

Console.WriteLine(now.ToString("u"));
Console.WriteLine(expires.ToString("u"));
Console.WriteLine(expires - now);
  • ToString("u") prints a time in a fixed, sortable form ending in Z, the UTC marker.
  • expires - now subtracts two DateTime values, which gives a TimeSpan.

Step 2: Run It​

Terminal
dotnet run main.cs
Output
2026-11-26 06:18:20Z
2026-11-26 06:33:20Z
00:15:00

A zsh terminal where dotnet run main.cs prints 2026-11-26 06:18:20Z, 2026-11-26 06:33:20Z and 00:15:00.

Your times will differ; the gap stays 00:15:00, hours, minutes and seconds. The command is the same in zsh, bash and PowerShell.

UtcNow, Not Now​

DateTime.Now is the computer's local time, which changes with the time zone and daylight saving. DateTime.UtcNow doesn't, and it says so: its Kind is Utc, while DateTime.Now.Kind is Local. Use UTC for anything you store or send.

Common Mistakes​

MistakeWhat happensDo this instead
Calling now.AddMinutes(15); without keeping the resultNothing changes: the original stays at its timeAssign it: var later = now.AddMinutes(15);
Using DateTime.Now for stored timesValues shift with the server's time zone and daylight savingUse DateTime.UtcNow
Adding a number to a DateTime with +error CS0019: Operator '+' cannot be applied to operands of type 'DateTime' and 'int'Use AddMinutes, or + TimeSpan.FromMinutes(15)

Troubleshooting​

SymptomLikely causeFix
A time didn't move after AddMinutesThe returned value was thrown awayKeep the return value
Times are hours off on another serverLocal time was usedSwitch to DateTime.UtcNow

FAQ​

How do I go back in time?​

Pass a negative number: AddMinutes(-15) is a quarter of an hour earlier.

Is there a version with a time-zone offset?​

Yes. DateTimeOffset.UtcNow.AddMinutes(15) works the same way and keeps an explicit +00:00 offset.

Conclusion​

DateTime.UtcNow.AddMinutes(15) gives the UTC time 15 minutes from now as a new value, and subtracting two times gives a TimeSpan. Keep the result of AddMinutes, because it never changes the original.

Additional Resources​