DateTime.SpecifyKind Method

Creates a new DateTime object that represents the same time as the specified DateTime, but is designated in either local time, Coordinated Universal Time (UTC), or neither, as indicated by the specified DateTimeKind value.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public:
static DateTime SpecifyKind (
	DateTime value, 
	DateTimeKind kind
)
public static DateTime SpecifyKind (
	DateTime value, 
	DateTimeKind kind
)
public static function SpecifyKind (
	value : DateTime, 
	kind : DateTimeKind
) : DateTime
Not applicable.

Parameters

value

A DateTime object.

kind

One of the DateTimeKind values.

Return Value

A new DateTime object consisting of the same time represented by the value parameter and the DateTimeKind value specified by the kind parameter.

A DateTime object consists of a Kind field that indicates whether the time value is based on local time, Coordinated Universal Time (UTC), or neither, and a Ticks field that contains a time value measured in 100-nanosecond ticks. The SpecifyKind method creates a new DateTime object using the specified kind parameter and the original time value.

The SpecifyKind method is useful in interoperability scenarios where you receive a DateTime object with an unspecified Kind field, but you can determine by independent means that the Ticks field represents local time or UTC.

The following code example uses the SpecifyKind method to demonstrate how the Kind property influences the ToLocalTime and ToUniversalTime conversion methods.

No code example is currently available or this language may not be supported.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show: