Avatar of sbornstein2
sbornstein2
 asked on

ASP.Net/C# - convert datetime question

We have our oracle database and web server in the EST timezone.  My web application I either need to show GMT to the user or conver the EST datetime to their local datetime, which is my ultimate goal.

Any idea how to do either or?

Thanks
ASP.NETC#

Avatar of undefined
Last Comment
sbornstein2

8/22/2022 - Mon
vora_bhaumik

Public Shared Function ConvertoDate(ByVal dateString As String, ByRef result As DateTime) As Boolean
        Try
            Dim supportedFormats() As String = New String() {"MM/dd/yyyy", "MM/dd/yy", "ddMMMyyyy", "dMMMyyyy"}

            result = DateTime.ParseExact(dateString, supportedFormats, System.Globalization.CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None)

            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function
Obadiah Christopher

vora_bhaumik

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER CERTIFIED SOLUTION
vora_bhaumik

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
sbornstein2

ASKER
One of the posts is using the DateTime.Now which I can't do as I already have it stored as EST and the other posts are using assuming it is central time to UTC.
sbornstein2

ASKER
this was perfect thank you