Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Converting the time from one timezone to another (http://www.velocityreviews.com/forums/t119890-converting-the-time-from-one-timezone-to-another.html)

Nathan Sokalski 02-18-2006 07:19 AM

Converting the time from one timezone to another
 
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
njsokalski@hotmail.com
http://www.nathansokalski.com/



William Stacey [MVP] 02-18-2006 07:31 AM

Re: Converting the time from one timezone to another
 
See my UTC project for sql. It has the c# class you need.
http://channel9.msdn.com/ShowPost.aspx?PostID=142586

--
William Stacey [MVP]
|



Nathan Sokalski 02-18-2006 05:53 PM

Re: Converting the time from one timezone to another
 
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
njsokalski@hotmail.com
http://www.nathansokalski.com/

"William Stacey [MVP]" <william.stacey@gmail.com> wrote in message
news:epuJU1FNGHA.3276@TK2MSFTNGP09.phx.gbl...
> See my UTC project for sql. It has the c# class you need.
> http://channel9.msdn.com/ShowPost.aspx?PostID=142586
>
> --
> William Stacey [MVP]
> |
>
>




William Stacey [MVP] 02-18-2006 11:44 PM

Re: Converting the time from one timezone to another
 
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" <njsokalski@hotmail.com> wrote in message
news:%23ji$GRLNGHA.916@TK2MSFTNGP10.phx.gbl...
|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
| njsokalski@hotmail.com
| http://www.nathansokalski.com/
|
| "William Stacey [MVP]" <william.stacey@gmail.com> wrote in message
| news:epuJU1FNGHA.3276@TK2MSFTNGP09.phx.gbl...
| > See my UTC project for sql. It has the c# class you need.
| > http://channel9.msdn.com/ShowPost.aspx?PostID=142586
| >
| > --
| > William Stacey [MVP]
| > |
| >
| >
|
|



Sandor Heese 02-23-2006 07:25 PM

Re: Converting the time from one timezone to another
 
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" <njsokalski@hotmail.com> wrote in message
news:OZBJ1uFNGHA.2300@TK2MSFTNGP15.phx.gbl...
>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
> njsokalski@hotmail.com
> http://www.nathansokalski.com/
>




clintonG 03-02-2006 04:13 PM

Re: Converting the time from one timezone to another
 
Thanks so much for posting that URL Sandor...

<%= Clinton Gallagher

"Sandor Heese" <nospam@nospam.com> wrote in message
news:%23axbo7KOGHA.2268@TK2MSFTNGP09.phx.gbl...
> 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" <njsokalski@hotmail.com> wrote in message
> news:OZBJ1uFNGHA.2300@TK2MSFTNGP15.phx.gbl...
>>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
>> njsokalski@hotmail.com
>> http://www.nathansokalski.com/
>>

>
>





All times are GMT. The time now is 05:51 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.