Easter Time Zone to UTC

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

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.
 
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.
 
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.
 
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.
 
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.
 
Back
Top