C# TimeZone ToUniversalTime
Description
TimeZone ToUniversalTime
returns the Coordinated Universal
Time (UTC) that corresponds to a specified time.
Syntax
TimeZone.ToUniversalTime
has the following syntax.
public virtual DateTime ToUniversalTime(
DateTime time
)
Parameters
TimeZone.ToUniversalTime
has the following parameters.
time
- A date and time.
Returns
TimeZone.ToUniversalTime
method returns A DateTime object whose value is the Coordinated Universal Time (UTC) that
corresponds to time.
Example
The following code shows how to use TimeZone.ToUniversalTime()
.
/*from w w w. jav a 2 s. c o m*/
using System;
using System.Globalization;
class TimeZoneDemo
{
static void Main( )
{
TimeZone localZone = TimeZone.CurrentTimeZone;
Console.WriteLine(localZone.ToUniversalTime(DateTime.Now) );
}
}
The code above generates the following result.