Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Converting the time from one timezone to another

Reply
Thread Tools

Converting the time from one timezone to another

 
 
Nathan Sokalski
Guest
Posts: n/a
 
      02-18-2006
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.
--
Nathan Sokalski
http://www.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/


 
Reply With Quote
 
 
 
 
William Stacey [MVP]
Guest
Posts: n/a
 
      02-18-2006
See my UTC project for sql. It has the c# class you need.
http://channel9.msdn.com/ShowPost.aspx?PostID=142586

--
William Stacey [MVP]
|


 
Reply With Quote
 
 
 
 
aweska don
Guest
Posts: n/a
 
      02-18-2006
Thanks

http://www.newbestweb.com owner

 
Reply With Quote
 
Nathan Sokalski
Guest
Posts: n/a
 
      02-18-2006
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 Removed)
http://www.nathansokalski.com/

"William Stacey [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> See my UTC project for sql. It has the c# class you need.
> http://channel9.msdn.com/ShowPost.aspx?PostID=142586
>
> --
> William Stacey [MVP]
> |
>
>



 
Reply With Quote
 
William Stacey [MVP]
Guest
Posts: n/a
 
      02-18-2006
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]

"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:%23ji$(E-Mail Removed)...
|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 Removed)
| http://www.nathansokalski.com/
|
| "William Stacey [MVP]" <(E-Mail Removed)> wrote in message
| news:(E-Mail Removed)...
| > See my UTC project for sql. It has the c# class you need.
| > http://channel9.msdn.com/ShowPost.aspx?PostID=142586
| >
| > --
| > William Stacey [MVP]
| > |
| >
| >
|
|


 
Reply With Quote
 
Sandor Heese
Guest
Posts: n/a
 
      02-23-2006
have a look at this MSDN article:

Coding Best Practices Using DateTime in the .NET Framework
http://msdn.microsoft.com/library/de...tetimecode.asp

it contains a lot of info about how to convert between timezones etc.

Sandor

"Nathan Sokalski" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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.
> --
> Nathan Sokalski
> (E-Mail Removed)
> http://www.nathansokalski.com/
>



 
Reply With Quote
 
clintonG
Guest
Posts: n/a
 
      03-02-2006
Thanks so much for posting that URL Sandor...

<%= Clinton Gallagher

"Sandor Heese" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> have a look at this MSDN article:
>
> Coding Best Practices Using DateTime in the .NET Framework
> http://msdn.microsoft.com/library/de...tetimecode.asp
>
> it contains a lot of info about how to convert between timezones etc.
>
> Sandor
>
> "Nathan Sokalski" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>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.
>> --
>> Nathan Sokalski
>> (E-Mail Removed)
>> http://www.nathansokalski.com/
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting time historic GMT to local time by specifying a timezone Tharinda C++ 3 08-25-2010 05:32 PM
Converting from one timezone to another kramesh Java 1 04-21-2009 02:46 PM
TimeZone change - how to use TimeZone class axrock Java 8 03-25-2009 11:54 PM
Convert windows TimeZone to Java TimeZone asaf Java 3 09-11-2006 05:40 PM
Converting the time from one timezone to another Nathan Sokalski ASP .Net 5 03-02-2006 04:13 PM



Advertisments