C# DateTime ToLocalTime
Description
DateTime ToLocalTime
converts the value of the current
DateTime object to local time.
Syntax
DateTime.ToLocalTime
has the following syntax.
public DateTime ToLocalTime()
Returns
DateTime.ToLocalTime
method returns An object whose Kind property is Local, and whose value is the local time equivalent
to the value of the current DateTime object, or MaxValue if the converted
value is too large to be represented by a DateTime object, or MinValue if the
converted value is too small to be represented as a DateTime object.
Example
The following code shows how to use DateTime.ToLocalTime
method.
using System;/*w w w. j av a 2 s.c om*/
public class Example
{
public static void Main()
{
DateTime date1 = new DateTime(2010, 3, 14, 2, 30, 0, DateTimeKind.Local);
DateTime date2 = date1.ToLocalTime();
Console.WriteLine("{0} --> {1}", date1, date2);
}
}
The code above generates the following result.