473,394 Members | 1,829 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,394 software developers and data experts.

Convert Local Time To Pacific Time

I am trying to convert a computers local time to Pacific time, I can
get it back to UTC pretty easy but I actually want to convert whatever
the local time is on the computer I want to calculate what it would
currently be in Pacific time. Taking in account Daylight Savings Time

Thanks, Ed,
Nov 20 '05 #1
5 5746
Have a look at the TimeZone class

HTH
Brian W
"ECVerify.com" <go****@gencode.com> wrote in message
news:20**************************@posting.google.c om...
I am trying to convert a computers local time to Pacific time, I can
get it back to UTC pretty easy but I actually want to convert whatever
the local time is on the computer I want to calculate what it would
currently be in Pacific time. Taking in account Daylight Savings Time

Thanks, Ed,

Nov 20 '05 #2
"Brian W" <brianw@gold_death_2_spam_rush.com> wrote in message news:<u0**************@TK2MSFTNGP12.phx.gbl>...
Have a look at the TimeZone class

HTH
Brian W
"ECVerify.com" <go****@gencode.com> wrote in message
news:20**************************@posting.google.c om...
I am trying to convert a computers local time to Pacific time, I can
get it back to UTC pretty easy but I actually want to convert whatever
the local time is on the computer I want to calculate what it would
currently be in Pacific time. Taking in account Daylight Savings Time

Thanks, Ed,


Brian, thanks but I have already looked there, but it seems that you
can only "Get" the current time zone...there is no way that I cna see
with that class to calculate a GMT time to a time in a time zone that
is not the local time of the computer it is on. But you can convert
the GMT tome with TimeZone to Local time, and that would work if the
users computers were in California, but they are not.
I did come up wit the following fuction but feel that Windows "should"
have a way to do it.

Public Shared Function UTCToPacificTime(ByVal UTC As DateTime)
As DateTime
Dim PacTime As DateTime
Dim StandardTime As Boolean = True

If (UTC.AddHours(-8).Month > 10 AndAlso
UTC.AddHours(-8).Month < 3) Then
StandardTime = False
End If

If ((UTC.AddHours(-8).DayOfWeek = DayOfWeek.Sunday)
AndAlso (UTC.AddHours(-8).Day > 24)) Then
If (UTC.AddHours(-8).Month = 10) AndAlso
(UTC.AddHours(-8).Hour > 2) Then
StandardTime = False
ElseIf (UTC.AddHours(-8).Month = 3) AndAlso
(UTC.AddHours(-8).Hour < 2) Then
StandardTime = False
End If
End If
If (StandardTime) Then
PacTime = UTC.AddHours(-8)
Else
PacTime = UTC.AddHours(-7)
End If

Return PacTime
End Function
Ed,
Nov 20 '05 #3
Ot

"ECVerify.com" <go****@gencode.com> wrote in message
news:20**************************@posting.google.c om...
I did come up wit the following fuction but feel that Windows "should"
have a way to do it.

Ed,


I would suggest that you ask a different question. (I don't know that
answer either and would be interested.)

The "new" question:

Is there a way to manipulate the Local Time Zone that is settable by the
Control Panel : Date and Time Settings : Time Zone?

Can one detect and save the current setting?

If so... Then ...

Set CTZ = Current Time Zone
Set Current Time Zone to pacific (with automatic Daylight Savings
Detection)
Use elements of TimeZone class as needed
Reset CurrentTimeZone to CTZ.

Regards,
Ot
p.s. Your detection of IsDaylightTime in the code you provided needs
refinement. It is built in to the TimeZone class (for local time) and if
you run the app only in the US and not in AZ or HI (where there is not
daylight savings time) then you can use TimeZone's.
Nov 20 '05 #4
"Ot" <ur***@tds.invalid (use net)> wrote in message news:<uM**************@TK2MSFTNGP12.phx.gbl>...
"ECVerify.com" <go****@gencode.com> wrote in message
news:20**************************@posting.google.c om...
I did come up wit the following fuction but feel that Windows "should"
have a way to do it.

Ed,


I would suggest that you ask a different question. (I don't know that
answer either and would be interested.)

The "new" question:

Is there a way to manipulate the Local Time Zone that is settable by the
Control Panel : Date and Time Settings : Time Zone?

Can one detect and save the current setting?

If so... Then ...

Set CTZ = Current Time Zone
Set Current Time Zone to pacific (with automatic Daylight Savings
Detection)
Use elements of TimeZone class as needed
Reset CurrentTimeZone to CTZ.

Regards,
Ot
p.s. Your detection of IsDaylightTime in the code you provided needs
refinement. It is built in to the TimeZone class (for local time) and if
you run the app only in the US and not in AZ or HI (where there is not
daylight savings time) then you can use TimeZone's.


Thanks for all the help, well I found a class with source and it is
phenomenal, in case others may want it here it is, it does all I
wanted and more.

http://www.michaelbrumm.com/simpletimezone.html

Once again thanks, Ed,
Nov 20 '05 #5
"Ot" <ur***@tds.invalid (use net)> wrote in message news:<uM**************@TK2MSFTNGP12.phx.gbl>...
"ECVerify.com" <go****@gencode.com> wrote in message
news:20**************************@posting.google.c om...
I did come up wit the following fuction but feel that Windows "should"
have a way to do it.

Ed,


I would suggest that you ask a different question. (I don't know that
answer either and would be interested.)

The "new" question:

Is there a way to manipulate the Local Time Zone that is settable by the
Control Panel : Date and Time Settings : Time Zone?

Can one detect and save the current setting?

If so... Then ...

Set CTZ = Current Time Zone
Set Current Time Zone to pacific (with automatic Daylight Savings
Detection)
Use elements of TimeZone class as needed
Reset CurrentTimeZone to CTZ.

Regards,
Ot
p.s. Your detection of IsDaylightTime in the code you provided needs
refinement. It is built in to the TimeZone class (for local time) and if
you run the app only in the US and not in AZ or HI (where there is not
daylight savings time) then you can use TimeZone's.


Thanks for all the help, well I found a class with source and it is
phenomenal, in case others may want it here it is, it does all I
wanted and more.

http://www.michaelbrumm.com/simpletimezone.html

Once again thanks, Ed,
Nov 20 '05 #6

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

Similar topics

0
by: EpochClock | last post by:
Africa/Abidjan Africa/Accra Africa/Addis_Ababa Africa/Algiers Africa/Asmera Africa/Bangui Africa/Bissau Africa/Blantyre Africa/Bujumbura Africa/Cairo
6
by: Rebecca Smith | last post by:
Today’s question involves two time text boxes each set to a different time zone. Initially txtCurrentTime will be set to Pacific Time or system time. This will change with system time as we travel...
2
by: David Berman | last post by:
Suppose you have a bulletin board where of course people can post messages and read messages composed by other people. Each message has a time stamp on it. When someone in California comes to the...
29
by: Jan | last post by:
Hi: I have an Access database that's been running (in one form or another) for a couple of different clients for a few years. Now a new client has requested that it be implemented with a SQL...
0
by: brianlum | last post by:
Hi, I need to if a calendar function works for different time zones. I can get the time of UTC and local time by doing: DateTime utc = System.DateTime.UtcNow; DateTime local =...
1
by: davelist | last post by:
I'm guessing there is an easy way to do this but I keep going around in circles in the documentation. I have a time stamp that looks like this (corresponding to UTC time): start_time =...
2
by: ZR | last post by:
Hello, I need to convert a GMT time string to local time. I can fill out a "tm" structure with the GMT time string. Are there any standard C (or OS) time functions that will allow me to do this? ...
8
by: deepak_kamath_n | last post by:
Hello, I have the following scenario: 1. My application receives the date from another application as a string 2. The other application is running in a different time zone as compared to my...
1
DTV12345
by: DTV12345 | last post by:
Hello! I am attempting to create a query that calculates a time value from GMT to Pacific time. It is, of course, based on the calendar date that I will have to figure out whether or not...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.