By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,453 Members | 3,225 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,453 IT Pros & Developers. It's quick & easy.

Convert Local Time To Pacific Time

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
"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

P: n/a
"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 discussion thread is closed

Replies have been disabled for this discussion.