473,799 Members | 3,006 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ToUn iversalTime()

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.AddHour s(-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.AddHour s(GetTZOffset(T imeZones.EST))

Is there a function that does this, or any way to get the offset by
submitting the timezone? Thanks.
--
Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/
Feb 18 '06 #1
5 1926
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********@hotm ail.com
http://www.nathansokalski.com/

"William Stacey [MVP]" <wi************ @gmail.com> wrote in message
news:ep******** ******@TK2MSFTN GP09.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********@hot mail.com> wrote in message
news:%2******** *******@TK2MSFT NGP10.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********@hotm ail.com
| http://www.nathansokalski.com/
|
| "William Stacey [MVP]" <wi************ @gmail.com> wrote in message
| news:ep******** ******@TK2MSFTN GP09.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********@hot mail.com> wrote in message
news:OZ******** ******@TK2MSFTN GP15.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.ToUn iversalTime()

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.AddHour s(-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.AddHour s(GetTZOffset(T imeZones.EST))

Is there a function that does this, or any way to get the offset by
submitting the timezone? Thanks.
--
Nathan Sokalski
nj********@hotm ail.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******** ********@TK2MSF TNGP09.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********@hot mail.com> wrote in message
news:OZ******** ******@TK2MSFTN GP15.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.ToUn iversalTime()

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.AddHour s(-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.AddHour s(GetTZOffset(T imeZones.EST))

Is there a function that does this, or any way to get the offset by
submitting the timezone? Thanks.
--
Nathan Sokalski
nj********@hotm ail.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
9261
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 time? Thanks in advance for any advice.
4
11882
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 timezone information), is there a generic way to do this? 2. Is there a general for converting time between timezones in ASP? Many thanks
6
4838
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 W3C note: http://www.w3.org/TR/NOTE-datetime For my requirements the code would be need to be open sourceable under the BSD license.
2
6771
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 representation of the time elapsed since the epoch, in GMT. Thus, a function that returns the current timestamp should always return the same value, regardless of timezone. The display of that value may change based on the system's timezone,...
1
1171
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 ballot and result pages depending on if the election is going on or has ended. I have couple of quick questions:
7
2684
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 convert them all to UTC and thus get them all on a common time-line. But I can’t see how to do this. I can use TimeZone.CurrentTimeZone to get the current TimeZone object and use its ToUniversalTime method to convert dates that occurred in the...
1
4081
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 to a timestamp (seconds since the # epoch), subtracts the timezone offset (in seconds), and then converts
7
2736
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
3913
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 MySQL (which treats all dates at local dates by default), it will already have incorporated the proper UTC offset. I've tried looking through the docs http://python.active-venture.com/lib/datetime-datetime.html), but have not had any luck.
0
10268
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10247
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9079
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7571
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5593
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.