Wednesday, October 16, 2013

Converting time zone in asp.net,C# and vb.net through framework 3.5.

First add below references.

Namespace:  System
Assembly:  System. Core (in System. Core. dell)

Sample function that works for all of you.

Create below function in common classes.

  Public Function GmtToPacific (ByVal dateTime As DateTime) As DateTime
        Return TimeZoneInfo. ConvertTimeFromUtc (dateTime, TimeZoneInfo. FindSystemTimeZoneById ("Pacific Standard Time"))

    End Function

Calls this function and pass input date in UTC/GMT format.

Dim objName as new CommonClassName

objName .GmtToPacific(sinceDate.ToUniversalTime.ToString())


No comments:

Post a Comment