Converting the time from one timezone to another

N

Nathan Sokalski

I asked a question about a week ago about how to get my local time, since my
application is running on a server halfway around the world. I have
determined that my code would look something like this:

Dim servertime As Date = Date.Now

Dim utctime As Date = servertime.ToUniversalTime()

Dim localtime As Date


I know that the last step would be to adjust the utctime value by the
appropriate amount using code such as utctime.AddHours(-5), but I am looking
for a way to get this value by supplying the timezone rather than an offset
(in other words, I am looking for a function that returns either a
System.TimeSpan or Integer when I enter the timezone) so that I can do
something such as

utctime.AddHours(GetTZOffset(TimeZones.EST))

Is there a function that does this, or any way to get the offset by
submitting the timezone? Thanks.
 
N

Nathan Sokalski

I could not find any code or links to download code on the page you gave a
link to. Also, even though I will be using the code for SQL in some cases,
my goal is to generate a System.DateTime object that is the local time. If I
am missing the code, please let me know exactly where on your page it is.
Thanks.
 
W

William Stacey [MVP]

There is a "Save" link at the bottom of the article. Easy to miss. The
APIs get and return DateTime, so you should be ok. Can use with sql or
without. Let me know if you still have problems.

--
William Stacey [MVP]

|I could not find any code or links to download code on the page you gave a
| link to. Also, even though I will be using the code for SQL in some cases,
| my goal is to generate a System.DateTime object that is the local time. If
I
| am missing the code, please let me know exactly where on your page it is.
| Thanks.
| --
| Nathan Sokalski
| (e-mail address removed)
| http://www.nathansokalski.com/
|
| | > See my UTC project for sql. It has the c# class you need.
| > http://channel9.msdn.com/ShowPost.aspx?PostID=142586
| >
| > --
| > William Stacey [MVP]
| > |
| >
| >
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top