Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

System.DateTime: practical reference

System.DateTime: practical reference: DateTime combines a date and clock time with a Kind of Utc, Local, or Unspecified.

Version: .NET API; verified on .NET 10.0.14

Syntax

System.DateTime /* select a documented member or constructor */

DateTime combines a date and clock time with a Kind of Utc, Local, or Unspecified.

Use it with an explicit Kind; DateTimeOffset is often safer for events exchanged between systems.

Kind does not store an arbitrary time zone, and daylight-saving rules create invalid or ambiguous local times.

Its range is finite, and local conversions depend on the machine time-zone configuration.

The complete program actually uses System.DateTime; its exact expected stdout is 2026-11-17T12:00:00.0000000Z.

Examples

using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;

var instant = new DateTime(2026, 11, 17, 12, 0, 0, DateTimeKind.Utc);
Console.WriteLine(instant.ToString("O", CultureInfo.InvariantCulture));

Result

2026-11-17T12:00:00.0000000Z

The complete program actually uses `System.DateTime`; its exact expected stdout is `2026-11-17T12:00:00.0000000Z`.

Sources