Click or drag to resize

DateTimeHelperConvertTimeZoneToLocal Method

Converts time zone of date to current time zone.

Namespace:  Xcalibur.Helpers
Assembly:  Xcalibur.Helpers (in Xcalibur.Helpers.dll) Version: 1.0.1.0 (1.0.1.0)
Syntax
public static DateTime ConvertTimeZoneToLocal(
	this DateTime date
)

Parameters

date
Type: SystemDateTime
The date.

Return Value

Type: DateTime

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type DateTime. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Examples
C#
 1static void Main(string[] args)
 2{
 3    // January 1, 2017 GMT
 4    var date = new DateTime(2017, 1, 1, 0, 0, 0, DateTimeKind.Utc);
 5    Console.WriteLine($"Date in GMT:\n{date:MM/dd/yyyy HH:mm:ss}");
 6
 7    // Spacer
 8    Console.WriteLine();
 9
10    // Convert to EST
11    Console.WriteLine($"Date in EST:\n{date.ConvertTimeZoneToLocal():MM/dd/yyyy HH:mm:ss zzz}");
12
13    // Hold
14    Console.Read();
15}
16
17/* Result:
18 *
19 * Date in GMT:
20 * 01/01/2017 00:00:00
21 *
22 * Date in EST:
23 * 12/31/2016 19:00:00 -05:00
24 */
See Also