473,561 Members | 3,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5777
Have a look at the TimeZone class

HTH
Brian W
"ECVerify.c om" <go****@gencode .com> wrote in message
news:20******** *************** ***@posting.goo gle.com...
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_de ath_2_spam_rush .com> wrote in message news:<u0******* *******@TK2MSFT NGP12.phx.gbl>. ..
Have a look at the TimeZone class

HTH
Brian W
"ECVerify.c om" <go****@gencode .com> wrote in message
news:20******** *************** ***@posting.goo gle.com...
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 UTCToPacificTim e(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.Sunda y)
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.c om" <go****@gencode .com> wrote in message
news:20******** *************** ***@posting.goo gle.com...
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.inva lid (use net)> wrote in message news:<uM******* *******@TK2MSFT NGP12.phx.gbl>. ..
"ECVerify.c om" <go****@gencode .com> wrote in message
news:20******** *************** ***@posting.goo gle.com...
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.inva lid (use net)> wrote in message news:<uM******* *******@TK2MSFT NGP12.phx.gbl>. ..
"ECVerify.c om" <go****@gencode .com> wrote in message
news:20******** *************** ***@posting.goo gle.com...
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
46274
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
2841
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 across the country. txtRaceTime will always be set to Central Time regardless of where we are in the US. At first I tried ‘Now() – “xx:xx:xx” but...
2
1787
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 site to read a message posted by someone in New York, how do you display the time from the timestamp in Pacific time, but when someone in New York...
29
2618
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 server back-end. I'm doing my best to learn about SQL server, and I plan to leave the front-end more or less as-is, just linking to the SQL server...
0
1143
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 = System.DateTime.Now; That would give me UTC and local time, so in my case, it would be Pacific Time. But how can I change my timezone so that I can get the
1
14582
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 = '2007-03-13T15:00:00Z' I want to convert it to my local time. start_time = time.mktime(time.strptime(start_time, '%Y-%m-%dT%H:%M:
2
18158
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? "subtracting ### hours depending on the locale" is not an option because I need this to work on any machine anywhere in the world, unless there is...
8
6037
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 app. 3. I need to convert the received date string in to a date w.r.t my local time zone.
1
2355
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 daylight savings applies (i.e. subtract 7 or 8 hours to get Pacific time). In this query below, "LVDURATION.START_TIME" is expressed in GMT time: I have...
0
7644
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7568
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7858
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8085
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...
1
7614
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...
0
6206
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...
0
3615
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...
0
3598
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1180
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.