473,321 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

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
nj********@hotmail.com
http://www.nathansokalski.com/
Feb 18 '06 #1
5 1912
See my UTC project for sql. It has the c# class you need.
http://channel9.msdn.com/ShowPost.aspx?PostID=142586

--
William Stacey [MVP]
|
Feb 18 '06 #2
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
nj********@hotmail.com
http://www.nathansokalski.com/

"William Stacey [MVP]" <wi************@gmail.com> wrote in message
news:ep**************@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]
|

Feb 18 '06 #3
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" <nj********@hotmail.com> wrote in message
news:%2***************@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
| nj********@hotmail.com
| http://www.nathansokalski.com/
|
| "William Stacey [MVP]" <wi************@gmail.com> wrote in message
| news:ep**************@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]
| > |
| >
| >
|
|
Feb 18 '06 #4
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" <nj********@hotmail.com> wrote in message
news:OZ**************@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
nj********@hotmail.com
http://www.nathansokalski.com/

Feb 23 '06 #5
Thanks so much for posting that URL Sandor...

<%= Clinton Gallagher

"Sandor Heese" <no****@nospam.com> wrote in message
news:%2****************@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" <nj********@hotmail.com> wrote in message
news:OZ**************@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
nj********@hotmail.com
http://www.nathansokalski.com/


Mar 2 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Monty | last post by:
Let's say you provide an online service from 7:00AM to 6:00PM Eastern Time (daylight time in the summer). Is there way of showing these hours of availability on a web page in the user's local...
4
by: Elie Grouchko | last post by:
Hi All 1. I need to convert the local-time of the server on which I run my website to UTC and I don't want to rely on the server local time and timezone (i.e. I don't want to hardcode the...
6
by: Jim Davis | last post by:
Before I reinvent the wheel I thought I'd ask: anybody got a code snippet that will convert the common ISO8601 date formats to a JS date? By "common" I mean at the least ones described in this...
2
by: Jason Priebe | last post by:
I'm a bit confused about SET TIME ZONE and its effect on PostgreSQL's date processing. In my experience with timestamps in all other *nix-based software systems, a timestamp is always a numeric...
1
by: Burak | last post by:
Hello, I am working on an election site. The users are going to enter the start and end times as well as the US time zone (EST/CST/etc..) for an election. Then we are supposed to display the...
7
by: Dick | last post by:
I have a long list of events. I know where each event took place (globally) and when (using the event’s local time). I want to do some comparisons between these date/times. I thought I would...
1
by: Matt | last post by:
Hi all, So a lot of digging on doing this and still not a fabulous solution: import time # this takes the last_modified_date naive datetime, converts it to a # UTC timetuple, converts that...
7
by: Correia | last post by:
I have a webserver that is in another country and have a different time zone. How can i fix this and use the scripts with the correct time zone? Thanks
11
by: Keith Hughitt | last post by:
Hi, I am having a little trouble figuring out how to convert a python datetime to UTC. I have a UTC date (e.g. 2008-07-11 00:00:00). I would like to create a UTC date so that when I send it to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.