How it works
DateTimeOffset combines a clock reading with an offset from UTC. Two values can display different local hours while referring to the same instant. This makes it useful for timestamps crossing system or geographic boundaries, where a bare local clock reading is not enough to identify a point on the timeline.
An offset is not a time-zone identifier. It describes the relationship to UTC at one value, but it does not contain a region's full history or future daylight-saving rules. This lesson avoids dependence on the device's local zone by supplying offsets directly. That makes the comparison deterministic and keeps the distinction between an instant and a regional calendar policy visible.
Walk through the example. The first timestamp reads ten o'clock at an offset of plus two hours. The second reads eight o'clock at UTC. Equality reports true because both identify the same instant. Converting the first value to UTC prints the matching eight o'clock representation. Adding ninety minutes produces a later instant, and subtracting the original yields a duration of ninety minutes.
Watch the boundary. Comparing formatted strings compares text, not necessarily instants. A label that sorts well in one fixed-offset format can be misleading when offsets differ. Also avoid assuming that adding a fixed number of hours implements a regional appointment rule across daylight-saving changes. Elapsed durations and calendar schedules are different requirements, even when a simple example happens to make them look equivalent.
Practice independently. Create three prepared timestamps using explicit offsets, including two representations of the same instant. Sort them as DateTimeOffset values and print a UTC report. Then calculate the elapsed duration between the earliest and latest instants. Describe the additional time-zone information that would be required to schedule a recurring local appointment, and explain why an offset alone would not supply it.
A working example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
var local = new DateTimeOffset(2026, 1, 2, 10, 0, 0, TimeSpan.FromHours(2));
var utc = new DateTimeOffset(2026, 1, 2, 8, 0, 0, TimeSpan.Zero);
Console.WriteLine(local == utc);
Console.WriteLine(local.ToUniversalTime().ToString("yyyy-MM-dd HH:mm zzz", CultureInfo.InvariantCulture));
var later = local.AddMinutes(90);
Console.WriteLine((later - local).TotalMinutes.ToString(CultureInfo.InvariantCulture));
Expected output
True 2026-01-02 08:00 +00:00 90
Compare typed instants; an offset does not contain a region’s daylight-saving rules.