PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Easter Time Zone to UTC
Forums
Newsgroups
Microsoft DotNet
Microsoft Dot NET Compact Framework
Easter Time Zone to UTC
![]() |
Easter Time Zone to UTC |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
If I have the time in New York, NY, how do I convert it to UTC? Keeping in
mind that NY uses Daylight Savings and I don't think UTC does. |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Hi,
The only way that I know of is slightly messy. I'd feed datetime (starting with your local time - Now, in descending order, by one hour increments) to TimeZone.CurrentTimeZone.ToLocalTime(UTCDateTime) as the UTCDateTime argument. When the return value is the same as your local time, the UTCDateTime is the actual UTC time. Dick -- Richard Grier (Microsoft Visual Basic MVP) See www.hardandsoftware.net for contact information. Author of Visual Basic Programmer's Guide to Serial Communications, 3rd Edition ISBN 1-890422-27-4 (391 pages) published February 2002. |
|
|
|
#3 |
|
Guest
Posts: n/a
|
That will convert the device time to UTC. That's not what I want to do. I
can't depend on the time on the device to be correct. I'm getting the correct New York time and I need to set the device time to that, no matter where the device is in the U.S. "Dick Grier" <dick_grierNOSPAM@msn.com> wrote in message news:uVUQL%236JEHA.2580@TK2MSFTNGP12.phx.gbl... > Hi, > > The only way that I know of is slightly messy. I'd feed datetime (starting > with your local time - Now, in descending order, by one hour increments) to > > TimeZone.CurrentTimeZone.ToLocalTime(UTCDateTime) as the UTCDateTime > argument. When the return value is the same as your local time, the > UTCDateTime is the actual UTC time. > > Dick > > -- > Richard Grier (Microsoft Visual Basic MVP) > > See www.hardandsoftware.net for contact information. > > Author of Visual Basic Programmer's Guide to Serial Communications, 3rd > Edition ISBN 1-890422-27-4 (391 pages) published February 2002. > > |
|
|
|
#4 |
|
Guest
Posts: n/a
|
So, you know the time in NY, but not the correct local time, the offset from
NY, or the correct GMT? It sounds like what you want to do is convert the NY time to GMT and then use SetSystemTime() on the device. This will tell the device, in combination with its time zone settings, what its local time should be. The OpenNETCF library has the necessary declarations to do much of this. Only the conversion from NY time to GMT would have to be your responsibility. Are you sure that you can't get the current time in GMT instead? That's a *far* more standard time reference and you could set the time with a single line of code: OpenNETCF.Win32.DateTimeEx.SetSystemTime( gmt ); Paul T. "Mike" <mikeotown@nospam.msn.com> wrote in message news:Okri9B7JEHA.1132@TK2MSFTNGP12.phx.gbl... > That will convert the device time to UTC. That's not what I want to do. I > can't depend on the time on the device to be correct. I'm getting the > correct New York time and I need to set the device time to that, no matter > where the device is in the U.S. > > "Dick Grier" <dick_grierNOSPAM@msn.com> wrote in message > news:uVUQL%236JEHA.2580@TK2MSFTNGP12.phx.gbl... > > Hi, > > > > The only way that I know of is slightly messy. I'd feed datetime > (starting > > with your local time - Now, in descending order, by one hour increments) > to > > > > TimeZone.CurrentTimeZone.ToLocalTime(UTCDateTime) as the UTCDateTime > > argument. When the return value is the same as your local time, the > > UTCDateTime is the actual UTC time. > > > > Dick > > > > -- > > Richard Grier (Microsoft Visual Basic MVP) > > > > See www.hardandsoftware.net for contact information. > > > > Author of Visual Basic Programmer's Guide to Serial Communications, 3rd > > Edition ISBN 1-890422-27-4 (391 pages) published February 2002. > > > > > > |
|
|
|
#5 |
|
Guest
Posts: n/a
|
I'm now getting the UTC time. But, yes, what I was trying to do is convert
NY time to GMT. "Paul G. Tobey [eMVP]" <ptobey_no_spam@instrument_no_spam.com> wrote in message news:OVVQGg7JEHA.2704@TK2MSFTNGP10.phx.gbl... > So, you know the time in NY, but not the correct local time, the offset from > NY, or the correct GMT? It sounds like what you want to do is convert the > NY time to GMT and then use SetSystemTime() on the device. This will tell > the device, in combination with its time zone settings, what its local time > should be. > > The OpenNETCF library has the necessary declarations to do much of this. > Only the conversion from NY time to GMT would have to be your > responsibility. Are you sure that you can't get the current time in GMT > instead? That's a *far* more standard time reference and you could set the > time with a single line of code: > > OpenNETCF.Win32.DateTimeEx.SetSystemTime( gmt ); > > > Paul T. |
|
|
|
#6 |
|
Guest
Posts: n/a
|
In order to do that, you need to either parse the time zone information when
the device is set to NY and then adjust the time, or you just have to know what the offset is based on the date. There's no ConvertTimezone( sourceTimezone, destinationTimeZone, datetime ) call... Paul T. "Mike" <mikeotown@nospam.msn.com> wrote in message news:OTETwM8JEHA.2888@TK2MSFTNGP09.phx.gbl... > I'm now getting the UTC time. But, yes, what I was trying to do is convert > NY time to GMT. > > "Paul G. Tobey [eMVP]" <ptobey_no_spam@instrument_no_spam.com> wrote in > message news:OVVQGg7JEHA.2704@TK2MSFTNGP10.phx.gbl... > > So, you know the time in NY, but not the correct local time, the offset > from > > NY, or the correct GMT? It sounds like what you want to do is convert the > > NY time to GMT and then use SetSystemTime() on the device. This will tell > > the device, in combination with its time zone settings, what its local > time > > should be. > > > > The OpenNETCF library has the necessary declarations to do much of this. > > Only the conversion from NY time to GMT would have to be your > > responsibility. Are you sure that you can't get the current time in GMT > > instead? That's a *far* more standard time reference and you could set > the > > time with a single line of code: > > > > OpenNETCF.Win32.DateTimeEx.SetSystemTime( gmt ); > > > > > > Paul T. > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

