TimeZoneInfo.ConvertTimeToUtc Method (DateTime, TimeZoneInfo)
Converts the time in a specified time zone to Coordinated Universal Time (UTC).
Assembly: mscorlib (in mscorlib.dll)
static member ConvertTimeToUtc : dateTime:DateTime * sourceTimeZone:TimeZoneInfo -> DateTime
- Type: System.DateTime
The date and time to convert.
- Type: System.TimeZoneInfo
The time zone of dateTime.
sourceTimeZone.IsInvalidDateTime(dateTime) returns true.
sourceTimeZone is a null reference (Nothing in Visual Basic).
If dateTime corresponds to an ambiguous time, this method assumes that it is the standard time of the source time zone. If dateTime corresponds to an invalid time, this method throws an ArgumentException.Notes to Callers
On Windows XP systems, the method applies only the current adjustment rule to the time zone conversion if sourceTimeZone is TimeZoneInfo.Local. As a result, the method may not accurately convert times for periods before the current adjustment rule came into effect. For more information, see the Notes for Callers section in the Local property.
The following example retrieves the current date from the local system and converts it to Coordinated Universal Time (UTC), then converts it to Tokyo Standard Time, and finally converts from Tokyo Standard Time back to UTC. Note that the two UTC times are identical.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.