NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DateTime.ToUniversalTime

Converts local time to UTC.

[Visual Basic]
Public Function ToUniversalTime() As DateTime
[C#]
public DateTime ToUniversalTime();
[C++]
public: DateTime ToUniversalTime();
[JScript]
public function ToUniversalTime() : DateTime;

Return Value

A new DateTime obtained by calculating the difference between UTC and local time and adding the result to or subtracting it from the current DateTime.

Exceptions

Exception Type Condition
ArgumentOutOfRangeException If the universal time is less than zero.

Remarks

The ToUniversalTime method creates a new DateTime object by converting this DateTime object to the coordinated universal time (UTC) time zone (see GetUTCOffset).

Note   The local time is equal to UTC plus the offset.

ToUniversalTime calculates the difference between the local time (the time zone of the current thread) and UTC and adds the result to or subtracts it from the current DateTime. For example, if UTC is five hours ahead of the local time, then the return value will be five hours ahead of the value of the current DateTime object.

See Also

DateTime Structure | DateTime Members | System Namespace | TimeZone | DateTimeFormatInfo | UTF7Encoding | UTF8Encoding | System.DirectoryServices.IADsPropertyValue.UTCTime